5

I have two shapefiles, a polygon shapefile (lake) and a line shapefile (boudary) I want to create a new shapefile containing the polygon splitted by the polyline using ogr2ogr.

oginal shapes

Result how can i do this?

2
  • 2
    It is not clear what do you mean by 'Split'? Can you elaborate a bit more? Commented Mar 5, 2017 at 18:20
  • i edited the post think you Commented Mar 6, 2017 at 8:41

2 Answers 2

4

If we have GDAL OGR with Spatialite support and liblwgeom (e.g. OSGeo4W):

ogr2ogr splitted_lake.shp lake.shp -dialect sqlite -sql "SELECT ST_Split(g1.geometry,g2.geometry) AS geometry FROM lake AS g1, 'boundary.shp'.'boundary' AS g2" -explodecollections 
1
0

After an hour of trying to understand the ST_Split approach, I instead simply by hand extended the boundary to wrap around the back side of the half (of "F") I wanted, making a closed clipping polygon "A", and then used the documented ogr2ogr -clip* options. In fact I was so happy I did it again ("B").

Boundaries extended to make polygon

(I added arrows else as the labels are on the centers, and the centers are beyond the edges, it looks odd.)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.