Adjacent Feature Attributes
Normally a feature in FME is self-contained. It might get processed as a group at some point, but other than that it doesn’t have any relationship to other features in the workspace.
However, in some cases, the ability for a feature to access the attributes of other features is quite useful.
For example, take a tabular dataset of coordinates recorded as follows:
X | Y |
---|---|
+0.0 | +3.0 |
+3.2 | +0.0 |
-3.2 | +0.0 |
+0.0 | +3.4 |
+4.2 | +0.0 |
In this case each row is not an absolute coordinate; instead, it is an offset from the previous one. Therefore, to calculate the true coordinates, each feature needs to know the coordinates of the previous feature, so that it can apply the offset.
This sort of scenario is catered for by Adjacent Feature Attributes in FME.
Adjacent Feature Functionality
Adjacent Feature functionality is activated by checking the box labeled Enable Adjacent Feature Attributes in an AttributeCreator or AttributeManager transformer:
This opens up a section of dialog in which the author can specify how many features preceding the current feature, or how many features that succeed it, should be made available. In the above screenshot attributes from the previous feature will become available.
Using Multiple Feature Attributes
The simplest way to make use of the attributes retrieved from prior/subsequent features is through the text or arithmetic editors, where the list of feature attributes has an expandable section for prior and subsequent features:
Attributes become available not only for the current feature but also for previous/subsequent features that have been exposed. As with the current attribute, double-clicking an adjacent attribute adds it to the expression window:
In the above screenshot, the workspace author is finding the time difference between two adjacent records in a business license dataset.
You can see that prior attribute values can be accessed simply by using feature[-x].
FME Lizard says… |
Be aware that extra system resources are used for storage of adjacent features. Therefore translation performance will take a (fairly minor) hit when using these capabilities, the degree of which depends on the number of features and the number of attributes being retained. |
Missing Values
The AttributeCreator and AttributeManager also have an option to specify what should happen if the attributes being used in a string are missing:
When the transformer tries to use a value that is missing (or null or empty) this option lets the user choose a replacement value, or to carry out no substitution.
Notice that this setting applies to attributes of the current feature, just as much as attributes of adjacent features.
FME Lizard asks... |
Q) My AttributeManager sets up NewAttribute = OldAttribute + feature[+1].OldAttribute |