Skip to main content

I have some polygons, but I need points (centroid) with an attribute, which holds the maximum distance from the centroid to the polygon-border. I can get the centroid (centerpointExtractor), but how can I get the maximum distance?

Thanks

Vera

Hi @vki, this might be a possible way.

  1. Counter: Add a sequential number attribute (e.g. "_count") to each polygon as temporary unique identifier.
  2. Chopper (Mode: By Vertex, Maximum Vertices: 1): Decompose the boundary of each polygon into individual vertex points.
  3. VertexCreator (Mode: Add Point): Add the center point to each vertex point to form a line segment connecting between the vertex and the center point.
  4. LengthCalculator: Calculate the length for each line segment.
  5. Sorter: Sort the line segments by length descending.
  6. DuplicateFilter (Key Attributes: _count): Pick the first (i.e. the longest) line segment for each polygon. The length of the resulting line is the "maximum distance" of a polygon.

I came up with an alternative solution, but I think the one @takashi came up with is better actually, the downside of mine is that you have to set a max distance in the NeighborFinder and it has to be big enough to catch your maximum centroid-boundary distance.


I tried Takashi's solution and stumbled over another post of him:

https://knowledge.safe.com/answers/21680/view.html

>> I just need a rough approximation of the distance, so this is perfect for me.

Thanks!


I see you have an answer, but I will chip in my 2c for posterity and say that the Triangulator transformer might be another solution. Basically compute triangles and select the one with the longest edge. It's what first came to mind for me.

As I was taught as a land surveyor, if in doubt, chop it into triangles!


Reply