[R-sig-Geo] New locations added with gIntersection() using a self-intersecting Line
Roger Bivand
Roger.Bivand at nhh.no
Fri Jan 13 19:01:31 CET 2012
On Fri, 13 Jan 2012, Pinaud David wrote:
> Dear all,
>
> I 'm intersecting a Line with a Polygon using gIntersection() in the rgeos
> package.
> When I'm using gIntersection() with a "self-intersecting" Line, the "clipped"
> Line is correctly created, but a node is also added corresponding to the
> "self intersection" :
This is most likely a feature of JTS/GEOS, see:
http://www.vividsolutions.com/jts/bin/JTS%20Technical%20Specs.pdf
pp. 27-28.
Roger
>
> library(rgeos)
> Le chargement a nécessité le package : sp
> Le chargement a nécessité le package : stringr
> rgeos: (SVN revision 287)
> GEOS runtime version: 3.3.1-CAPI-1.7.1
> Polygon checking: TRUE
> WARNING! if you turn polygon checking off, and polygons are
> not valid in GEOS, you risk losing data as your R session may crash!
> Po1 <- readWKT("POLYGON((0 0,0 2,1 3.5,3 3,4 1,3 0,0 0))")
> Lin1 <- readWKT("LINESTRING(0 3,1 1,2 2,3 0.5, 1 2.5, 3.5 2.5)")
> Lin1po1 <- gIntersection(Lin1, Po1)
> coordinates(Lin1po1) # new segments are created, with new endpoints at
> (1.75, 1.75)
> plot(Po1, axes=T, col="grey")
> plot(Lin1, add=T)
> plot(as(Lin1po1, "SpatialPoints"), add=T, col="red")
>
> # even with no intersection with a larger polygon:
> Po2 <- readWKT("POLYGON((-1 0,-1 3.5,4 4,4 -1,-1 0))")
> Lin1po2 <- gIntersection(Lin1, Po2)
> coordinates(Lin1po2) # new segments are created, with new endpoints at
> (1.75, 1.75)
> plot(Po2, axes=T, col="blue")
> plot(Lin1, add=T)
> plot(as(Lin1po2, "SpatialPoints"), add=T, col="red")
>
> In the last case, one could expect Lin1 and Lin1po2 to be strictly identical
> (same nodes).
> Is there a way to avoid the creation of such new location?
> Thanks for your help.
>
> David
>
>
--
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
Helleveien 30, N-5045 Bergen, Norway.
voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list