Dear geo-list, I'm just starting using R and the rgdal package to manage and create some shapes and I am hitting some speed issues while using the %over% function. R is significantly slower than ArcGIS.
Here is what I'm doing (I've shorten the code to make it easier to follow, I don't expect it to be reproducible). # I first load a shape giving the perimeter of the territory of interest terr <- readOGR("D:\\Couches GIS\\06152\\contour", "contour_carto06152_Project") # I then want to make a grid of points. The grid is very dense and rectangular # to do so, I first make a gridtopology grille.plac.temp1 <- GridTopology(...) # and get all the coordinates from the grid grille.plac.temp2 <- coordinates(grille.plac.temp1) # and finally transform it to a SpatialPointsDataFrame object grille.plac <- SpatialPointsDataFrame(grille.plac.temp2,data.frame(1:nrow(grille.plac.temp2)),proj4string =CRS(proj4string(terr))) # The grid is very big as it is a rectangle in which you can fit the territory shape # (which is of irregular shape). I then want to reduce it's size by keeping only # to points from the grid that are in the territory. I use the %over% function to do # that. This is the slow part. system.time(plac.dans.contour<-grille.plac%over%contour) user system elapsed 1420.23 9.57 1435.17 # I then make a new shape with only the points from the grid that are in the territory grille.plac.reduce <- grille.plac[as.vector(!is.na(plac.dans.contour)),] This code works fine and produce what I want it to produce. However, the %over% functions takes 24 minutes to run, while ArcGIS can run it in less than 1 minute with the intersect tool. Is there a more efficient function than %over% to do what I want? Is it normal that ArcGIS is that much faster than R in that case? Thanks for your help, Bastien Ferland-Raymond, M.Sc. Stat., M.Sc. Biol. Division des orientations et projets spéciaux Direction des inventaires forestiers Ministère des Ressources naturelles et de la Faune du Québec _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo