Rounds off attributes with numeric values to the specified number of decimal places. Rounding may be nearest, up, or down.
- 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.
Features with attributes to be rounded.
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.
|Attributes to Round||Select the source attribute(s) to round.|
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.
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.
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.
|FME Licensing Level||FME Base Edition and above|
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