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. 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.

NB: The transformer involved is actually the ValueMapper - forerunner of the current AttributeValueMapper - but the operation involved is exactly the same.

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

User-added image


Colour Calculator

Mapping values to a colour can be awkward because there is no colour selection tool within the transformer. This Colour Calculator from our reseller TYDAC will help you translate RGB, Hex and MapInfo colours into an FME supported style that you can use in this transformer.