rgeos gIntersection in loop takes too long to clip path network
问题 I am using gIntersection to clip a nationwide path network by polygons one at a time from a SpatialPolygonsDataFrame. I am looping through each polygon, clipping the path network, calculating the length of the clipped paths, and saving this to a dataframe called path.lgth: poly<-readShapePoly("C:\\temp\\polygons.shp") paths<-readShapeLines("C:\\temp\\paths.shp") #loop through all polygons clipping lines path.lgth<-data.frame() for (i in 1:length(poly)){ clip<-gIntersection(paths,poly[i,])