Hi all

I have this polygon and these lines:

library(sp); library(rgeos)
# polygon
coords <- matrix(c(-1.798123, -1.793072, -1.805767, -1.804129, -1.798123,
55.68066, 55.67369, 55.67508, 55.68139, 55.68066), ncol=2)
myPolygon <- Polygons(list(Polygon(coords)),  "myPolygon")
myPolygon <- SpatialPolygons(list(myPolygon))
proj4string(myPolygon) <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84
+towgs84=0,0,0")
plot(myPolygon)

# lines
line1 <- matrix(c(-1.79880, -1.79517, 55.67737, 55.67920), ncol=2)
line2 <- matrix(c(-1.80231, -1.80679, 55.67764, 55.68004), ncol=2)
line1L <- Line(line1)
line2L <- Line(line2)
my.lines <- Lines(list(line1L, line2L), ID="my.lines")
myLines <- SpatialLines(list(my.lines))
proj4string(myLines) <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84
+towgs84=0,0,0")
plot(myLines, add=T)



I expected that the code below would remove parts of myPolygon that contain
myLines:

d <- gDifference(myPolygon, myLines)
plot(d)


However myPolygon seems unaffected. Why are the parts of myPolygon that
contain myLines not being removed?

Thanks
Ross



        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to