SIngle Python script in scripts/poly2raster. Test case is
Exterior ring in blue, red dots indicate crossings on exterior ring. Green lines are inner lines, inner crossings are not represented.
Steps:
Split exterior ring. This gives a list of splits for the exterior ring (blue splits) but also crossings on the exterior ring (exterior_crossings)
Split along horizontal gridlines. For each y level inside bounding box (y = 1,2 and 3 in example), split segments between two crossings that are inside the polygon. This relies on helper split_along_gridlines
Split along vertical gridlines (same as 2)
Concatenate lists of splits (of type LineString) and build split polygons using shapely.ops.polygonize
SIngle Python script in![polygon_scaled](https://user-images.githubusercontent.com/13448239/127994141-f54af5af-4e8f-4324-8174-9ba89901462b.png)
scripts/poly2raster
. Test case isExterior ring in blue, red dots indicate crossings on exterior ring. Green lines are inner lines, inner crossings are not represented.
Steps:
exterior_crossings
)y
level inside bounding box (y = 1,2 and 3 in example), split segments between two crossings that are inside the polygon. This relies on helpersplit_along_gridlines
LineString
) and build split polygons usingshapely.ops.polygonize
Result:![Figure_1](https://user-images.githubusercontent.com/13448239/127995756-8e6a5f0d-74ac-4e22-8ac9-0498d15aed21.png)