Dear All, I have a shapefile wich contents are polygons. I sort two (here random) points and I would like to identify if the line built with this two points cross or not polygons and in case yes, which polygons were crossed. I tryed to figure out the problem with a sample code got from sp/maptools packages.
Kind regards, Miltinho Brazil == require(maptools) grd <- GridTopology(c(1,1), c(1,1), c(10,10)) polys <- as.SpatialPolygons.GridTopology(grd) centroids <- coordinates(polys) x <- centroids[,1] y <- centroids[,2] z <- 1.4 + 0.1*x + 0.2*y + 0.002*x*x ex_1.7 <- SpatialPolygonsDataFrame(polys, data=data.frame(x=x, y=y, z=z, row.names=sapply(slot(polys, "polygons"), function(i) slot(i, "ID")))) ex_1.7.selected<-ex_1.7[c(2,5,10,25,28,23,43,55),] plot(ex_1.7.selected,axes=T,xlim=c(0,12),ylim=c(0,12)) set.seed(1) my.lines<-NULL for (i in 1:5) { df<-cbind(x=runif(2)*10,y=runif(2)*10) my.lines[i]<-list(df) lines(df,col=(i+1)) } para armazenamento! [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.