FME Version
Files
-
- 100 KB
- Download
Introduction
Measuring distances is very simple in FME. However, much data is stored with Latitude and Longitude coordinates, and that complicates measure distances. Distances are rarely required to be measured as decimal degrees, but instead units such as feet or meters.
For this purpose, there are two transformers that provide a solution: the ReprojectLengthCalculator and the GeographicLengthCalculator.
ReprojectLengthCalculator
The ReprojectLengthCalculator transformer accepts line lengths in one coordinate system and calculates what that length would be in a second coordinate system:
The transformer does not measure the geometry of the incoming features, but instead calculates the result based on incoming values/attributes. Also, it is accurate only to within 0.2% or so, 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. For an example about using the ReprojectLengthCalculator, please see the article Distance Measurements with the LengthCalculator.
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:
The transformer does measure the geometry of the 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 downloaded from the FME Hub.
Step-by-step Instructions
Follow these steps as an example of how to take features in lat/long, and calculate their length in metres...
1. Start FME Workbench and generate a workspace to translate the attached source data from Google KML to OGC GeoPackage format. Choose a file name for the output, and - when prompted - select only the Neighborhood reader feature type:
2. Using Quick Add, add a GeographicLengthCalculator transformer between the reader and writer feature types:
If the transformer has not already been downloaded from the FME Hub, it will be downloaded and installed automatically.
3. Open the parameters dialog for the GeographicLengthCalculator transformer. Ensure the Distance Unit is set to Meters, and that the Length Attribute parameter is set to write an attribute called NeighborhoodPerimeter:
4. Open the parameters dialog for the writer feature type. Click the User Attributes tab and change the Attribute Definition type to Automatic:
This will ensure all attributes that are read or created will be written in the output.
5. Save and run the workspace. Notice that, even though the source and destination datasets use Latitude and Longitude coordinates, the NeighborhoodPerimeter attribute is measured in metres:
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia (data.vancouver.ca). It contains information licensed under the Open Government License - Vancouver.
Comments
0 comments
Please sign in to leave a comment.