FME Transformers: 2024.1
FME Transformers: 2024.1
AttributeValueMapper
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.
Typical Uses
- 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 Input 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 Input 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 Input and Output 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 Output Value, which may be left blank.
Additional Value Settings
Default Output Value, Input Value, and Output Value can be set to a fixed value, or can use an FME predefined value. In the case of Input and Output values, these may be set per line in the Value Map table, and so different attribute values may prompt different actions.
Values available are:
Null |
Input Value: Input null values will be mapped to a output value. Output Value: The source value will be mapped to a null output value. The reverse is true if Mapping Direction is set to Reverse (Output to Input). |
No Action |
No action will be taken. When mapping in-place (that is, if the new value is overwriting the input value), the input attribute value will be preserved. Otherwise, no output attribute will be created for the input value specified. |
Support for Null, Missing, and Empty String Values
When mapping from input to output, there are three attribute values that are not supported by the Default Output 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.
Examples
Example: Performing a simple value mapping
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 Input Attribute, keep the default Output Attribute name _looked_up, and assign a Default Output 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 Input 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.
Example: Cleaning up attribute 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 Input Value as DESCRIPTION. We are not importing Output 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 Output 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 Output Attribute is the same as the Input 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.
Usage Notes
- if you need to map to or from null, missing, or empty string values, consider using NullAttributeMapper.
Configuration
Input Ports
Input
Features with attributes to be mapped.
Output Ports
Output
Features with the mapped attributes stored in either a new or existing attribute.
Parameters
Attribute Selection
Input Attribute |
The attribute whose values will be mapped. |
Output 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 Input Attribute. If an existing attribute or the Input Attribute is specified, the existing value of the attribute is overwritten. |
Value Map
Default Output Value |
The value to give the Output Attribute if the value of the Input Attribute is not found in the Value Map table. The reverse is true when Mapping Direction is set to Reverse (Output 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 Input Attribute. If, for example, you have entered a default value of KEY-0 and the Input 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 Input Attribute to the Output Attribute, or the reverse. This may be useful when switching directions, without having to recreate the entire lookup table reversed. |
||||||
Input Value & Output Value |
This table of values specifies the mapping information. When the Mapping Direction is set to Forward (Input To Output), if the value of the Input Attribute is specified in the Input Value column, the Output Attribute will be created with the value specified in the Output Value column corresponding to that input value. This process is reversed if the Mapping Direction is set to Reverse (Output to Input). The Input Value and Output 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. |
||||||
Import |
You can import attribute values (input value, output 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
Transformer parameters can be set by directly entering values, using expressions, or referencing other elements in the workspace such as attribute values or user parameters. Various editors and context menus are available to assist. To see what is available, click beside the applicable parameter.
How to Set Parameter Values
Defining Values
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.
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.
Conditional Values
Set values depending on one or more test conditions that either pass or fail.
Parameter Condition Definition Dialog
Content
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.
Content Types
These functions manipulate and format strings. | |
Special Characters |
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
Table Tools
Transformers with table-style parameters have additional tools for populating and manipulating values.
Row Reordering
|
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. |
Filter
|
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
|
Import populates the table with a set of new attributes read from a dataset. Specific application varies between transformers. |
Reset/Refresh
|
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.
For more information, see Transformer Parameter Menu Options.
Reference
Processing Behavior |
|
Feature Holding |
No |
Dependencies | None |
Aliases | ValueMapper |
History | Previously named ValueMapper |
FME Community
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, Open Government Licence - British Columbia, and/or Open Government Licence – Canada.