Question

Problem with LengthCalculator

  • 2 April 2018
  • 5 replies
  • 10 views

Badge

Hello,

 

I have a problem with the LenghtCalculator transformer. The point is that, when I calculate distances of linear segments I expect that visually long ones have bigger distance values but it's not exactly what happend.

 

I want to use it along with a TestFilter to delete lines of lenght below a value of my choice.

 

Thank you in advance.

 

Here is the shapefile I'm working in :

https://drive.google.com/open?id=1-vycWGAvos7pjCxE7tLXHroA69G1M5-G


5 replies

Userlevel 2
Badge +12

One issue that can occur (experienced it) is that you have self intersecting lines (lines that go back on itself).

The LengthCalculator will calculate the length of the line (including the not visible overlapping parts).

Userlevel 2
Badge +17

Hi @lianaolianov, in my observation, the LengthCalculator works fine on your sample Shapefile dataset. Just be aware the unit of the resulting length will be the same as the unit of distance in the coordinate system. Since the coordinate system of your dataset is LL-WGS84 (latitude, longitude), the unit of distance is degrees. If you need to get the length in other unit (e.g. meters), you will have to transform the geometry into an appropriate coordinate system before calculating the length.

Badge

Hi @lianaolianov, in my observation, the LengthCalculator works fine on your sample Shapefile dataset. Just be aware the unit of the resulting length will be the same as the unit of distance in the coordinate system. Since the coordinate system of your dataset is LL-WGS84 (latitude, longitude), the unit of distance is degrees. If you need to get the length in other unit (e.g. meters), you will have to transform the geometry into an appropriate coordinate system before calculating the length.

I have changed my projection's system unit and everything works fine.

 

Thank you very much.

 

 

Userlevel 4

There's also the GeographicLengthCalculator custom transformer on the FME Hub which will do all the work for you.

Badge +1

I assume you want the lengths of the 4 road segments? Note that you're not supposed to calculate lengths in a geographic coordinate system (like the WGS84 you're using). Always use a projected coordinate system, because only then the values will be correct. It's a matter of measuring distances on the right ellipsoid and datum. Using the Reprojector and setting it to EPSG:26191, I get values for the roads that are 20000 metres or more.

Also, when looking at the dataset and taking it through a GeometryValidator, I get errors in the data (_issues{0}.issue_found (string): Self-Intersections in 2D). It could be good to clean the data first, before you keep using this file.

Reply