Skip to main content
Solved

irregular polygon edges length

  • January 14, 2025
  • 9 replies
  • 63 views

boubcher
Contributor
Forum|alt.badge.img+11

hello there we need to calculate the length of each polygon edge , the polygona could be in irregular shape considering the polygon is 4 edges 
if we use chopper or Geometrycoercer  transformer we get many edge  we are suppose to get only 4 
Thanks
 

 

Best answer by geomancer

I can think of an algorithm for this particular polygon, but it will not work for all polygons.

For this polygon I would isolate the 2 longest segments, and combine the other segments if they are connecting to each other.

But this will not work when the two longest segments of your polygon share a vertex, or when the long segments are made up of several shorter segments. So this is by no means a complete solution.

The attached workspace makes use of the custom transformer PolylineAnalyzer from FME Hub. This transformer calculates a lot of other useful information, that may lead to other solutions.

 

9 replies

redgeographics
Celebrity
Forum|alt.badge.img+62

You can use a BoundingBoxReplacer, with the option to use a 2D oriented bounding box. It’ll be rectangular and will generate attributes for the length of the long and short sides (so multiply both by 2 to get the total circumference

If you need to retain the original geometry you can use a GeometryExtractor before and a GeometryReplacer after the BoundingBoxReplacer.


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • January 14, 2025

if I use the bounding box we will not get the exact value of the edge length for each side 


redgeographics
Celebrity
Forum|alt.badge.img+62

c


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • January 14, 2025

Can you provide some more information?

Of which 4 edges do you want to calculate the length?

Below I sketch 3 different possible definitions, but maybe you want yet another one.

 


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • January 14, 2025

@geomancer 
Thanks for the your response 
the Goal is to extract each  4 line and calculate their length 
as its is presented in color 

 

 


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • Best Answer
  • January 14, 2025

I can think of an algorithm for this particular polygon, but it will not work for all polygons.

For this polygon I would isolate the 2 longest segments, and combine the other segments if they are connecting to each other.

But this will not work when the two longest segments of your polygon share a vertex, or when the long segments are made up of several shorter segments. So this is by no means a complete solution.

The attached workspace makes use of the custom transformer PolylineAnalyzer from FME Hub. This transformer calculates a lot of other useful information, that may lead to other solutions.

 


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • January 14, 2025

I can think of an algorithm for this particular polygon, but it will not work for all polygons.

For this polygon I would isolate the 2 longest segments, and combine the other segments if they are connecting to each other.

But this will not work when the two longest segments of your polygon share a vertex, or when the long segments are made up of several shorter segments. So this is by no means a complete solution.

The attached workspace makes use of the custom transformer PolylineAnalyzer from FME Hub. This transformer calculates a lot of other useful information, that may lead to other solutions.

 

@geomancer   thanks for your help

Very useful 

 


boubcher
Contributor
Forum|alt.badge.img+11
  • Author
  • Contributor
  • January 15, 2025

@geomancer 
if we need to calculate the edge length for the below case what will be your approach
thanks 
 

 


geomancer
Evangelist
Forum|alt.badge.img+60
  • Evangelist
  • January 15, 2025

For this, I would start with isolating the 4 longest line segments, create a new polygon from those segments, and calculate the length of the 4 sides of that polygon.

Like my previous idea I suspect this may not work for all polygons.