Distance Measurements with the GeographicLengthCalculator

Sydney Dombowsky
Sydney Dombowsky
  • Updated

Introduction

Measuring distances in FME can be done in a variety of ways. However, much data is stored with Latitude and Longitude coordinates, which complicates measuring distances. Distances are rarely required to be calculated as decimal degrees, but instead in units such as feet or meters.

For this purpose, there are two transformers that provide a solution: the ReprojectLengthCalculator and the GeographicLengthCalculator.

Workspace

 

ReprojectLengthCalculator

The ReprojectLengthCalculator transformer accepts line lengths in one coordinate system and calculates what the length would be in a second coordinate system:

ReprojectLengthCalculator

The transformer does not measure the geometry of the incoming features, but instead calculates the result based on incoming values/attributes. Additionally, the accuracy is only within approximately 0.2%, depending on the coordinate system selected and the length of the line. This may be fine for smaller lines, but for large lengths, this can add up to a significant inaccuracy.

 

GeographicLengthCalculator

The GeographicLengthCalculator calculates the length of linear features (or the perimeter of polygon features) and returns the result as an attribute, using one of a selection of units:

GeographicLengthCalculator_Units

Unlike the ReprojectLengthCalculator, the GeographicLengthCalculator measures the geometry of incoming features. The units returned, regardless of the incoming coordinate system, can be Feet, Kilometers, Meters, or Miles.

The GeographicLengthCalculator transformer is not installed as part of FME. Instead, it must be installed either within the Transformer Gallery or the Quick Add dialog in FME Workbench. It can also be downloaded from the FME Hub and installed in FME Workbench.

 

Step-by-Step Instructions

In this example, we will take neighborhood features in Latitude and Longitude and use the GeographicLengthCalculator to calculate their length in meters. The workspace and source data can be downloaded from the Files section.

1. Start FME Workbench and Read Neighborhood Data

Start FME Workbench and click on New to open a blank workspace.

To add the neighborhood data, click the Reader button in the Toolbar. In the Add Reader dialog window, enter the following:

  • Format: OGC / Google KML
  • Dataset: /VancouverNeighborhoods.kml
    • Click on the ellipsis (blank document icon for macOS) and browse to the dataset

Then click OK.

KML-Reader

When prompted to select feature types, select only Neighborhoods, then click OK to add the Reader to the canvas.

  • Select Feature Types:
    • Select all: Disabled
    • Neighborhoods: Selected

Reader-FeatureTypes

 

2. Add a Writer to the Workspace

We want the final dataset to be in the OGC GeoPackage format, so we will add a Writer feature type for the output data to be written to.

Click Writer in the Toolbar and set the following parameters:

  • Format: OGC GeoPackage
  • Dataset: /Output
    • Choose the destination for your output dataset

Click OK. 

A Feature Type dialog box will pop up. Set the name for the output table, then click OK:

  • Table Name: Neighborhoods

OGCGeoPackage-Writer

 

3. Add a GeographicLengthCalculator Transformer

To calculate the length of each neighborhood in the dataset, we will use a GeographicLengthCalculator transformer.

Type GeographicLengthCalculator on the canvas to open the Quick Add dialog. Double-click or press Enter on the keyboard to add the transformer. 

Click Install in the dialog to confirm installation of the transformer.

Installation

 

If you don’t see the GeographicLengthCalculator, ensure the Community filter is selected:

CommunityFilter

Connect the Neighborhood reader feature type to the GeographicLengthCalculator Input port. Connect the GeographicLengthCalculator Output port to the Neighborhoods writer feature type:

GeographicLengthCalculator

 

4. Configure Transformer Parameters

We will configure the GeographicLengthCalculator parameters so the unit is meters, and a new attribute called _NeighborhoodPerimeter is created to store length values.

Double-click the GeographicLengthCalculator transformer to open the parameters dialog. Set the following:

  • Distance Unit for Calculating Length: Meters
  • Length Attribute: _NeighborhoodPerimeter

GeographicLengthCalculator-Parameters

Click OK.

 

5. Configure Writer Parameters

Open the parameters dialog for the writer feature type. Click the User Attributes tab and ensure the Attribute Definition type is set to Automatic:

  • User Attributes:
    • Attribute Definition: Automatic

Writer-Paramater

This will ensure all attributes that are read or created will be written to the output.

 

6. Run Workspace and View Results

Click the green Run button in the Toolbar to run the workspace. You can ignore the Unexpected Input warning and click OK.

To view the output data, click on the Neighborhoods writer feature type and then the View Written Data button:

ViewWrittenData

This will open the data in the Data Preview window:

DataPreview

Notice that, even though the source and destination datasets use Latitude and Longitude coordinates, the _NeighborhoodPerimeter attribute is measured in meters. 

You can find the dataset coordinate system in the Record Information window in Coordinate System Properties under Geometry. In this case, the coordinate system is LL-WGS84. If you click into the coordinate system, a parameters dialog will appear, where we can see that the unit of measurement for LL-WGS84 is degrees:

CoordinateSystem

If you want to take this example one step further, you can round the perimeter values using an AttributeRounder on the _NeighborhoodPerimeter attribute. For information about the AttributeRounder transformer, refer to the AttributeRounder Transformer Documentation.

 

Additional Resources

AttributeRounder Transformer Documentation

 

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.