Skip to main content

Hi,

I have a polygon with a donut hole, and I would like to split it in half, e.g. across the center of the donut hole. The result should be two polygons, as illustrated below. The polygon isn't necessarily always "horizontal," like in the example below; it could be rotated in any direction.

Does anyone know how to do this? Any help would be appreciated!

 

A polygon with a donut hole
Resulting polygons

 

Hi @davorink 

 

Do you have any sample data to share us?

 

Thanks in Advance,

Danilo


Try DonutBridgeBuillder + Deaggregator.


well, it’s difficult without the data. my first thoughts:

  • get the hole with the donutextractor, then get the CenterPoint

for the angle of the cut:

  • get the centerline of the objects
  • filter out the straight lines (delete the arcs)
  • get the longest line
  • get the angle of the line and add 90 degrees

for the length of the cut:

  • get the outer limits of the object (boundarybox)
  • calculate the crossing points of the line with the boundarybox (or “endless” lentgh)

the cut:

  • LineOnAreaOverlay

 

but not tested!


A slightly different approach:

  • Create a rotated boundary box of the original polygon, and obtain its width and rotation angle with a BoundingBoxReplacer
  • Get the coordinates of the center point of the hole with a DonutHoleExtractor and a CenterPointExtractor
  • Add these coordinates to the rotated bounding box with a FeatureMerger
  • Create the cutting line using the coordinates of the center point, the width and rotation angle of the rotated bounding box, and some math
  • Cut the original polygon with the cutting line

In the whole process group by some unique ID of the input polygons.

 


yeah, that’s a much easier way, thanks @geomancer 

I forgot the rotated BoundingBox. Interesting point of your workbench is, that the LineOnAreaOverlay doesn’t need a line as input. It seems, two vertex are also possible. Didn’t know that.


Interesting point of your workbench is, that the LineOnAreaOverlay doesn’t need a line as input. It seems, two vertex are also possible. Didn’t know that.

Actually my workbench does create a line. The first VertexCreator creates a point feature, the second VertexCreator adds a second point to that feature, turning it into a line feature.


Reply