Distance Measurements with the LengthCalculator

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2022.0

Measuring Distances

Measuring distances is - like measuring areas - very simple in FME. It requires the use of just one transformer; the LengthCalculator. Here, for example, a user is measuring the length of arterial road features:

The length of each road feature is measured and added to the feature as an attribute called RoadLength.

Length is measured in the units of the coordinate system being used. For example, if the source data is in a coordinate system based on metres (meters) then the LengthCalculator returns values in metres.

There are some simple variations and issues to be aware of.

  • The multiplier parameter sets a value by which the result is multiplied. This is most used when converting between units; for example if the source data is in metres and the multiplier is set to 3.28084, then the result will be in feet.
  • The result is calculated to a precision not usually required for most uses. The AttributeRounder is often used after the LengthCalculator to round the results to fewer decimal places.
  • A more advanced variation is to use the @Length() function inside a transformer such as the AttributeManager
  • The attribute created by the transformer needs to be added to the destination schema if it is to be recorded in the output.
  • A multi-line or aggregate feature returns a length that is the sum of its parts

Follow these steps as an example of how to calculate the length of linear features.

1. Start FME Workbench and generate a workspace to translate the attached source data from Esri Shapefile format back to Esri Shapefile format. Choose a different folder for the output.

2. Add a LengthCalculator transformer between the reader and writer feature types


3. Open the parameters dialog for the LengthCalculator transformer. Ensure the Length Attribute parameter is set to write an attribute called RoadLength


4. Open the parameters dialog for the writer feature type. Click the Attributes tab and add a new attribute called RoadLength of type float


5. Optionally add an AttributeRounder transformer after the LengthCalculator. Open its parameters dialog and set it up to round the RoadLength attribute to 3 decimal places.


6. Save and run the workspace. Inspect the output. Notice the new RoadLength attribute with values rounded to 3 decimal places


Why not take this example one step further by calculating the average length of the roads? You can use a StatisticsCalculator to calculate the average of all RoadLength values.


Initial Workspace as Template

Final Workspace as Template

Was this article helpful?



Please sign in to leave a comment.