Routes features to different output ports depending on the value of an attribute. The set of possible attribute values can be entered manually, or extracted from an input source in the properties dialog.
- Separating features based on attribute values for further individual processing
- Extracting one or more groups of features from a dataset based on attribute values
- Selecting features from a dataset that match specific values and discarding the rest
- Grooming a dataset by keeping select features and discarding features with non-matching, empty, missing, and/or null values
How does it work?
Once connected, the AttributeFilter lets you select an attribute to filter incoming features by. By default, Empty, Missing, Null, and Unfiltered outputs are provided, and you can specify additional values to filter by either entering them manually or importing values from an existing dataset.
All features are passed through the transformer, exiting via the appropriate output port.
Cached Values and Data-Aware Attributes
If Feature Caching is enabled, available attribute values from upstream features may be viewed and selected through the Cached Values option on the Possible Attribute Values dropdown menu.
In this beginning of a workspace, a CAD file containing road data is read, and the features divided into separate streams for further processing based on the autocad_layer attribute value.
The transformer has been connected to the incoming features from the Reader, and so the dataset’s attributes are available for selection. The autocad_layer attribute is chosen.
The desired values are entered, each on a separate row. The available values could also be determined by using the Import button to scan the contents of the dataset.
- Ideally, you will want to keep the filter list fairly small; otherwise you can end up with a very long list of attributes. If FME determines that the list might be too large, it will return a warning.
- If feature filtering can be done with groups or ranges of values, consider using the TestFilter or AttributeRangeFilter.
- If you are filtering features for the sole purpose of writing to separate layers or datasets, consider using Fanout instead.
- Feature ordering may be specified with the Advanced > Preserve Feature Order parameter.
This transformer accepts any feature.
|<Empty>||If the feature’s attribute value is an empty string, the feature is output via the <Empty> port.|
|<Missing><![CDATA[ ]]>||If the feature does not have the specified attribute, it is output via the <Missing> port.|
|<Null><![CDATA[ ]]>||If the feature’s attribute has a value of null, the feature is output via the <Null> port.|
|<Unfiltered><![CDATA[ ]]>||If the feature’s attribute has a value not in the list, the feature is output via the <Unfiltered> port. This port can be used for collecting all features with "positive" values, that is, values that are not missing, null, or empty.|
For each value entered in the Possible Attribute Values list, an output port is created with the same name as the value.
|Attribute to Filter by||
When you connect the transformer to the feature type, the list of attributes will appear in a pull-down list. Choose the attribute from the list.
If you know the values you wish to filter, enter them individually here, one per row. Each entry will create an output port.
You may also import values from a source dataset by using the Import button.
|<![CDATA[ ]]>Preserve Feature Order||
This parameter controls the order in which features exit a transformer.
When a transformer has more than one output port, features usually exit one port at a time. At times, it may be useful to keep the order that features arrived in, switching from port to port as necessary. This allows feature order to be preserved, though at a potential cost in processing efficiency.
Select a method for feature ordering.
Editing Transformer Parameters
Using a set of menu options, transformer parameters can be assigned by referencing other elements in the workspace. More advanced functions, such as an advanced editor and an arithmetic editor, are also available in some transformers. To access a menu of these options, click beside the applicable parameter. For more information, see Transformer Parameter Menu Options.
There are several ways to define a value for use in a Transformer. The simplest is to simply type in a value or string, which can include functions of various types such as attribute references, math and string functions, and workspace parameters. There are a number of tools and shortcuts that can assist in constructing values, generally available from the drop-down context menu adjacent to the value field.
Using the Text Editor
The Text Editor provides a convenient way to construct text strings (including regular expressions) from various data sources, such as attributes, parameters, and constants, where the result is used directly inside a parameter.
Using the Arithmetic Editor
The Arithmetic Editor provides a convenient way to construct math expressions from various data sources, such as attributes, parameters, and feature functions, where the result is used directly inside a parameter.
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Expressions and strings can include a number of functions, characters, parameters, and more.
When setting values - whether entered directly in a parameter or constructed using one of the editors - strings and expressions containing String, Math, Date/Time or FME Feature Functions will have those functions evaluated. Therefore, the names of these functions (in the form @<function_name>) should not be used as literal string values.
|These functions manipulate and format strings.|
|A set of control characters is available in the Text Editor.|
|Math functions are available in both editors.|
|Date/Time Functions||Date and time functions are available in the Text Editor.|
|These operators are available in the Arithmetic Editor.|
|These return primarily feature-specific values.|
|FME and workspace-specific parameters may be used.|
|Creating and Modifying User Parameters||Create your own editable parameters.|
Dialog Options - Tables
Transformers with table-style parameters have additional tools for populating and manipulating values.
Enabled once you have clicked on a row item. Choices include:
Cut, Copy, and Paste
Enabled once you have clicked on a row item. Choices include:
Cut, copy, and paste may be used within a transformer, or between transformers.
|Start typing a string, and the matrix will only display rows matching those characters. Searches all columns. This only affects the display of attributes within the transformer - it does not alter which attributes are output.|
|Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers.|
Generally resets the table to its initial state, and may provide additional options to remove invalid entries. Behavior varies between transformers.
Note: Not all tools are available in all transformers.
The FME Community is the place for demos, how-tos, articles, FAQs, and more. Get answers to your questions, learn from other users, and suggest, vote, and comment on new features.
Search for all results about the AttributeFilter on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver and/or the Open Government Licence – Canada.