[R-sig-Geo] New locations added with gIntersection() using a self-intersecting Line

Pinaud David pinaud at cebc.cnrs.fr
Fri Jan 13 17:11:57 CET 2012


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" :

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

-- 
***************************************************
Dr. David PINAUD
Ingénieur de Recherche "Analyses spatiales"

Centre d'Etudes Biologiques de Chizé - CNRS UPR1934
79360 Villiers-en-Bois, France
poste 485
Tel: +33 (0)5.49.09.35.58
Fax: +33 (0)5.49.09.65.26
http://www.cebc.cnrs.fr/

***************************************************

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pinaud.vcf
Type: text/x-vcard
Size: 324 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120113/561b796c/attachment.vcf>


More information about the R-sig-Geo mailing list