GIS Cookie Cutting Library/Algorithms?
Is there an open source GIS library available that provides cookie cutting? I have a series of polygons that are to be the cookie cutters, and then I have a series of geometries that I want to divide based on their location within the cookie cutting polygons.
If there's no library, is there a fairly simple algorithm for cookie cutting polygons? Points are easy, using OGR for example you can just loop through all polygons calling Contains() on each point. Lines are more difficult but seems reasonably straightforward using Intersection() and creating new lines with that.
Polygons strike me as using the same basic concepts, but more work. I was hoping som开发者_运维知识库eone already did this and made it public. Any thoughts?
Thanks much in advance.
Nevermind, OGR's Intersection() function returns lines/polygons if that's the intersection.
So if poly1 = [ (0,0), (1,0), (1,1) (0,1) ] and poly2 = [ (0.5,0), (1.5,0), (1.5,1), (0.5,1) ]
then poly1.Intersection(poly2) returns [ (1,0), (0.5,0), (0.5,1), (1,1) ]
So the algorithm in Python would just be:
new_geometries = []
For cutting_poly in cookie_cutter_polygons:
For g in all_geometries:
new_geometries.append(cutting_poly.Intersection(g))
Hope that helps someone.
精彩评论