Skip to main content
Question

get distance from centroid to outer boundary of polygon


vki
Contributor
Forum|alt.badge.img+7
  • Contributor

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

4 replies

takashi
Influencer
  • November 9, 2016

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.

redgeographics
Celebrity
Forum|alt.badge.img+49

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.


vki
Contributor
Forum|alt.badge.img+7
  • Author
  • Contributor
  • November 9, 2016

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!


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • November 9, 2016

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!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings