AttributeRounder
Rounds off attributes with numeric values to the specified number of decimal places. Rounding may be nearest, up, or down.
Typical Uses
- Rounding off numeric attribute values for presentation or consistency.
How does it work?
The AttributeRounder accepts any feature. It rounds the selected attribute(s) to the specified number of decimal places, which may be a fixed integer, or set to an attribute or parameter value.
The newly rounded values replace the original values, and all features are output.
Non-numeric values will be passed through unaltered. If rounding is attempted with Decimal Places set to a non-integer value, the features will be Rejected.
Negative Decimal Place integer values may be used to perform rounding to the left of the decimal, rounding to 10s, 100s, 1000s, and so forth.
In this example, a spreadsheet containing values will be rounded to 2 decimal places. The source data is not clean, containing one alphanumeric string mixed in with an assortment of numbers.
The features are routed into an AttributeRounder.
In the parameters dialog, we select attribute A for rounding (column A from the spreadsheet), and set the number of Decimal Places to 2. The Round-off Direction is left as Nearest, which rounds up or down as appropriate.
The values are rounded where possible, and replace the original attribute values. Note that numbers that had less than 2 decimal places to start with are not zero-padded, and the non-numeric string “Dogs” has been passed through unaltered.
Configuration
Input Ports
Features with attributes to be rounded.
Output Ports
All processed features are output through this port, whether rounding has been performed or not.
Features with attribute values of any type will be passed through the transformer and output, however, if Decimal Places is set to a non-integer the affected features will be output via the <Rejected> port.
Though it is not possible to directly enter a non-integer value for Decimal Places, it is possible to assign it to another attribute, parameter, or calculated value that could be invalid.
Rejected Feature Handling: can be set to either terminate the translation or continue running when it encounters a rejected feature. This setting is available both as a default FME option and as a workspace parameter.
Parameters
Attributes to Round | Select the source attribute(s) to round. |
Decimal Places |
Enter a number or take the value of a feature attribute by selecting the attribute name from the pull-down list. If the Decimal Places value is a negative integer then the integral part of the number will be rounded. For example, if the number is 12345.1234 and the decimal places value is -2, then the rounded value will be 12300.0. If the number to be rounded is a decimal value, and the Decimal Places value is not 0, then the rounded number will be a decimal value, possibly ending with .0. When the decimal places value is 0, the rounded number will always be an integer. If the Decimal Places value is not an integer, features will be output via the <Rejected> port. |
Round-off Direction |
This parameter controls how the rounding will take place.
|
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.
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. 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.
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 - whether entered directly in a parameter or constructed using one of the editors.
These functions manipulate and format strings. | |
A set of control characters is available in the Text Editor. | |
Math functions are available in both editors. | |
These operators are available in the Arithmetic Editor. | |
These return primarily feature-specific values. | |
FME and workspace-specific parameters may be used. | |
Working with User Parameters | Create your own editable parameters. |
Reference
Processing Behavior |
|
Feature Holding |
No |
Dependencies | |
FME Licensing Level | FME Base Edition and above |
Aliases | |
History | |
Categories |
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 AttributeRounder on the FME Community.
Examples may contain information licensed under the Open Government Licence – Vancouver