Compares attribute values to a lookup table and assigns new values where matches are found. Mapped values may be stored in a new attribute, or overwrite an existing attribute, including the original source.
- Adding or altering attribute values based on a user-defined lookup table
- Cleaning up attribute values
- Creating alternative, coded values for attributes
How does it work?
The AttributeValueMapper is driven by a user-defined lookup table - the Value Map. One source attribute is selected, which will have its values compared to the lookup table to map new values. The new values may be stored in a new attribute (default behavior), or can overwrite an existing attribute (including the Source Attribute).
The Value Map can either be created manually or by importing any FME-supported dataset. Importing is particularly useful for using a predefined map that already contains the Source and Destination Values (such as a spreadsheet), and for scanning a dataset to find all existing values for a given attribute.
If an attribute value is not found in the Value Map, the new attribute will be assigned the Default Value, which may be left blank.
Additional Value Settings
Default Value, Source Value, and Destination Value can be set to a fixed value, or can use an FME predefined value. In the case of Source and Destination values, these may be set per line in the Value Map table, and so different attribute values may prompt different actions.
Values available are:
Source Value: Source null values will be mapped to a destination value.
Destination Value: The source value will be mapped to a null destination value.
The reverse is true if Mapping Direction is set to Reverse (Destination to Source).
No action will be taken. When mapping in-place (that is, if the new value is overwriting the source value), the source attribute value will be preserved.
Otherwise, no destination attribute will be created for the source value specified.
|Stop Translation||If the specified source value is encountered, halt translation with the specified message. Useful when you wish to halt translation on unexpected attribute values, such as null values.|
Support for Null, Missing, and Empty String Values
When mapping from source to destination, there are three attribute values that are not supported by the Default Value parameter or the Value Map table. They are: missing, null, and empty string values. The exceptions are noted below.
It is possible to map or specify a default value of null by using the null constant, available on the parameter drop-down menu.
Further, it is possible to map a source value to a destination value of empty string, or to specify the empty string as the default value.
Note that if a missing or null value is specified as a destination value or default value via an attribute, it will be converted into an empty string.
In this example, we want to map an attribute in our bike path dataset. The original data has an attribute called PathType, with values of S, M, and L.
The features are routed into an AttributeValueMapper.
In the parameters dialog, we select PathType as the Source Attribute, keep the default Destination Attribute name _looked_up, and assign a Default Value of Unknown (which will be used for any feature that has a PathType not found in our lookup table).
For each of our possible Source Attribute values, we create a value pair in the Value Map.
The output features now have a new attribute, _looked_up, containing the mapped values.
In this example, we have a dataset of food vendors, in which the DESCRIPTION attribute values have a number of errors and style differences such as capitalization. There are also some values that we want to combine into broader categories.
The features are routed into an AttributeValueMapper. In order to find all possible values in the dataset, we will use the Import wizard in the parameters dialog.
The first step is to select the dataset to import - choose the same dataset we want to clean up.
Note that on the second dialog - Specify Import Mode - we need to change the Import Mode to Attribute Values.
Next, on the Select Attributes dialog, we specify the Source Value as DESCRIPTION. We are not importing Destination Values (as we might if loading a predefined value map), and so it is left blank. Click Import to finish.
The dataset is scanned for all existing values, and they are loaded into the Value Map. Then we complete the Destination Value side of the table. Note the following choices:
- All variations of Hot Dogs (hot dogs, HotDogs, HOT DOGS, and so forth) are mapped to Hot Dogs.
- Several values that are already in the desired form (Indian Cuisine, Italian Cuisine) have <No Action> assigned to them, and so will not be changed.
- Some related types are assigned a common name and so will be combined (Korean Cuisine, Mexican Cuisine).
Note that the Destination Attribute is the same as the Source Attribute. This will result in the new values overwriting the original values (except for those denoted as <No Action>).
The cleaned up output features reflect the desired changes.
- if you need to map to or from null, missing, or empty string values, consider using NullAttributeMapper.
Features with attributes to be mapped.
Features with the mapped attributes stored in either a new or existing attribute.
|Source Attribute||The attribute whose values will be mapped.|
|Destination Attribute||The attribute that will store the looked-up value. You can use the default name, or specify a new attribute name. Alternatively, you can type the name of an existing attribute, including the Source Attribute. If an existing attribute or the Source Attribute is specified, the existing value of the attribute is overwritten.|
The value to give the Destination Attribute if the value of the Source Attribute is not found in the Value Map table. The reverse is true when Mapping Direction is set to Reverse (Destination to Source).
The Default Value can be a constant or computed value (such as an attribute value), the value of a user parameter, the value of an FME parameter, or an expression containing the above.
You can also enter a default value containing the word KEY (uppercase), where KEY will be substituted by the value of the Source Attribute. If, for example, you have entered a default value of KEY-0 and the Source Attribute has a value d that is not in the mapping table, the destination attribute value will be set to d-0 because KEY is replaced by the original value d. If left blank and matching values are not found, an empty string is assigned.
|Mapping Direction||Determines whether values will be mapped from the Source Attribute to the Destination Attribute, or vice-versa. This may be useful when switching directions, without having to recreate the entire lookup table reversed.|
|Source Value & Destination Value||
This table of values specifies the mapping information.
When the Mapping Direction is set to Forward (Source to Destination), if the value of the Source Attribute is specified in the Source Value column, the Destination Attribute will be created with the value specified in the Destination Value column corresponding to that source value.
This process is reversed if the Mapping Direction is set to Reverse (Destination to Source).
The Source Value and Destination Value can be a constant value or a computed value such as an attribute value, the value of a user parameter, the value of an FME parameter, or an expression containing the above.
You can import attribute values (source value, destination value, or both) from any FME-supported source dataset.
This is commonly used to import all existing values from the dataset that is being mapped, or to import a predefined lookup table (often stored in a spreadsheet or text file). Click the Import button to launch the Import Wizard, and follow the prompts.
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.
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.
|History||Previously named ValueMapper|
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 AttributeValueMapper on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver and/or the Open Government Licence – Canada.