In am a Django developer with limited GIS knowledge. In Django I have a polygon and a linestring as follows:
I would like to split the polygon by the linestring to obtain the 4 resulting polygons (or one new multipolygon):
Based on the API docs I thought I might be able to use the union method to get this, but this fails on geometry checking.
Does anyone perhaps have a suggestion on how best to achieve this?
Best Answer
You can use shapely to access the underlying GEOS API and create the polygons:
Since GEOS is used by GeoDjango and shapely, data is interchangeable between them.
Solution adapted from answer here: https://stackoverflow.com/questions/4129241/split-a-polygon-with-a-linestring-in-jts