Other Key Filter Transformers
The Tester and TestFilter are not the only useful filter transformers.
AttributeFilter
The AttributeFilter transformer (#14 in the top 25) directs features on the basis of values in a chosen attribute. It is best for testing many values for a single attribute, for example:
- Is that road a Primary, Secondary, Residential, Private, or Other type of road?
- Is the forecast for sun, rain, snow, or fog?
In this example features are divided into different streams depending on the value of a RoadClass attribute.
In a workspace like this the repetition of Tester transformers indicates an AttributeFilter transformer might be a better option:
The AttributeFilter's only "operator" is to find equivalency, so you would rarely use it for arithmetical tests.
AttributeRangeFilter
The AttributeRangeFilter carries out the same operation as the AttributeFilter, except that it can handle a range of numeric values instead of just a simple one-to-one match.
The AttributeRangeFilter parameters dialog has the option to generate ranges automatically from a set of user-defined extents.
GeometryFilter
The GeometryFilter (#22 in the top 25) directs features on the basis of geometry type; for example, point, line, area, ellipse:
The GeometryFilter is useful for:
- Filtering out unwanted geometry types; for example removing non-linear features before using an AreaBuilder transformer
- Validating geometry against a list of permitted types; for example where the dataset is constrained to either point or area features (above)
- Dividing up geometry types to write to separate destination Feature Types; for example, when writing to a geometry-restricted format such as Esri Shapefile
Confused from Interopolis says... |
Dear Aunt Interop
If the Tester, TestFilter, and AttributeFilter all filter features on the basis of an attribute condition, then what’s the difference? When would I use each? |
Aunt Interop says... |
Dear Confused
The best solution is to check out these two articles on the Safe Software blog: - Conditional Processing in FME - A Simple Guide to FME Filter Transformers There's also a useful table I put together: |
Single Test | Multiple Tests | Test Type | Operators | Attributes | ||||
Single Clause | Multi Clause | Single Clause | Multi Clause | String | Numeric | (Number of) | (Number of) | |
Tester | Y | Y | – | – | Y | Y | 16 | Multiple |
TestFilter | Y | Y | Y | Y | Y | Y | 16 | Multiple |
AttributeFilter | Y | Y | – | – | Y | – | 1 | 1 |
AttributeRangeFilter | Y | Y | – | – | – | Y | 6 | 1 |