I've had examples in the past where using %over% from the sp package takes
all available RAM (7GB) and several hours, while ArcGIS takes about 300MB
and 5 minutes, so I would agree that there is plenty of room for
improvement here. I'll try to give a reproducable example in the coming
weeks when I return from travel.

This is a critical issue for me insofar as spatial joins are a routine
procedure for me and but without reasonable speed for producedures such as
this I cannot perform all my analysis in R, making for a more complex,
error prone work flow and scuttling the possibility of "reproducable
research."

On a related note, does the 'sp' package have an accessible bug tracker?
I'd like to be able to contribute to improving this very useful package if
at all possible, but I'm not sure where to begin.

Warm regards,

Francis Markham
Research Associate
Fenner School of Environment and Society
Australian National University

On 27 February 2012 19:18, Edzer Pebesma <edzer.pebesma@uni-muenster.de>wrote:

> Dear Bastien,
>
> the %over% method was primary written to work, and it seems that it did.
>
> It is hard to tell why ArcGIS is so much faster without access to its
> source code, and your data. Chances are that it uses a spatial index,
> and R does not.
>
> Talking about spatial indexes, you might want to try %over% in package
> rgeos (essentially after loading rgeos) as that seems to use a spatial
> index. Providing a reproducible example is always more inviting for
> someone on the list (possible me) to look deeper into this.
>
> If you want to obtain points on a regular grid within a polygon,
> sp::spsample with type "regular" may be an alternative route. Package
> raster may have more efficient routines for many things.
>
> On 02/27/2012 09:54 AM, Bastien.Ferland-Raymond@mrnf.gouv.qc.ca wrote:
> > 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
>
> --
> Edzer Pebesma
> Institute for Geoinformatics (ifgi), University of Münster
> Weseler Straße 253, 48151 Münster, Germany. Phone: +49 251
> 8333081, Fax: +49 251 8339763  http://ifgi.uni-muenster.de
> http://www.52north.org/geostatistics      e.pebesma@wwu.de
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]

