GIS utility to split complex multipolygons into simple polygons (closed rings without holes or multiple parts)
Dependencies
###Use
1. join_donuts.py Cut donuts by joining interior holes to the exterior via closest points (reccomended)
Usage: join_donuts.py <in_shp> <out_shp>
-or-
2. split_donuts.py Split donuts horizontally across holes
Usage: split_donuts.py <in_shp> <out_shp>
###Algorithm
join_donuts.py works as follows
- For each feature in a collection
- If it is a multipolygon split it into separate polygons
- For each polygon, check if it has any interior rings (holes)
- For each interior ring, find the closest point in the exterior ring to the centroid of the interior ring
- Then find the closest point in the interior ring to the point we just found
- Join the two rings together such that an edge now links the closest point in the exterior to the closest point in the interior, and treat this as the new exterior ring.
- Repeat steps 4-6 for the remaining interior rings with the new exterior ring
- Return the resulting polygons
split_donuts.py works as follows
- For each feature in a collection
- If it is a multipolygon split it into separate polygons
- For each polygon, check if it has any interior rings (holes)
- Pick a point in the hole. Return the left half and right half of the polygon.
- For each resulting polygon recursively check for holes
- Return the resulting polygons
###Tests
tests.py
e.g. multip.shp is split as follows:
join_donuts.py multip.shp outjoin.shp
split_donuts.py multip.shp out.shp