AttributeValueMapper
From fmepedia
AttributeValueMapper is a Workbench Transformer.
| Table of contents |
Description
This transformer assigns attribute values based upon other attributes; in other words it works more or less as a look-up table.
For example one could map fme_feature_type against fme_color to assign a different colour to each different type of feature.
Default Value
Any feature that does not map to a listed value is given the default value instead. The exact behaviour regarding null default values varies according to your version of FME.
- Up to FME2006GB, a blank default value meant that such features were mapped to a null value.
- In FME2007 and 2008, even though the documentation stated otherwise, a translation would fail if a feature failed to map and the default was left empty.
- In FME2009 or newer, a blank default value again means that unmapped features are given a null value and the translation will continue.
Importing Values
The original attribute values can be entered manually or imported from any FME supported source dataset. It is not possible to use the AttributeValueMapper's import option with attributes that are generated somewhere in the existing workspace. The most common use would be to import from the same dataset as is being mapped, but you could import the mappings from a lookup table stored in a text/CSV/Excel file or perhaps an 'example' dataset that specifically holds one of each type of feature.
Where only one side of the mapping is available for import - for example the source values are in the source data, but the mapped values are not - then it's recommended to select the same source attribute for both sides of the equation. That will give you a basic 1:1 mapping which can then be edited. If different values are chosen then the mapping may not be 1:1. Having said this, the AttributeValueMapper can be purposely used to map several source values to a single output value.
Example 1
The attached workspace shows an example use of the AttributeValueMapper transformer.
In this example a feature is generated with a random type (road, river or railroad) and with a random activity assumed to have taken place to it (a code numbered 1 to 4). The first AttributeValueMapper transformer assigns a colour according to the feature type - roads are red; rivers, blue; railroads, black. The second AttributeValueMapper transformer assigns a status according to the activity code - 1 = current, 2=under review, 3=revised, 4=deleted.
In other words the AttributeValueMappers are being used as a simple lookup table. This is a common technique used to map source features to a certain symbology according to their original feature type (layer).
You don't have to look too closely to realize there is actually a third AttributeValueMapper transformer - it's one of the transformers used to generate the sample data. See if you can figure out what it is doing.
Workspace Screenshot
Example 2
The CustomRangeClassifier custom transformer offers AttributeValueMapper-like functionality with the option to assign new values based on a value range, rather than a discrete value. Safe is also looking into creating an official AttributeClassifier - basically a AttributeValueMapper that allows you to work with ranges of data rather than a set value (eg 1-5 = A, 6-10 = B, 11-15 = C etc). If anyone is particularly interested in such a transformer please let us know via fmepedia@safe.com.
Colour Calculator
Mapping values to a colour can be awkward because there is no colour selection tool within the transformer. This Colour Calculator (http://www.tydac.ch/color/) from our reseller TYDAC (http://www.tydac.ch/) will help you translate RGB, Hex and MapInfo colours into an FME supported style that you can use in this transformer.

Hans - Hope you don't mind me editing this entry. Mireland 11:37, 16 Dec 2005 (PST)