Re: Using gIntersection to split polygons with lines
On 26/06/17 12:56, Frederico Mestre wrote:
> I'm trying to use gIntersection() to cut a polygon ("SpatialPolygons") with
> a line ("SpatialLinesDataFrame").
> I wanted to obtain a "SpatialPolygons" object with the polygons defined by
> the lines. This is what I did:
> polygons1 <- gIntersection(spgeom1=mypolygon, spgeom2=mylines)
> However I get an "SpatialLines" object as an output instead of a
> Am I doing something wrong? Is there any alternative?
Package sf has a function st_split() that cuts a polygon with a line,
similar to postgis' function st_split.
To use it, you'd need to build sf from source after having liblwgeom
installed; the CRAN binary builds do not have support for liblwgeom.