Skip to content

gIntersection versus intersect

2 messages · Jean-Luc Dupouey, Robert J. Hijmans

#
For intersecting two polygon layers, is there any advantage of using 
gIntersection (from the rgeos package) instead of intersect (from the 
raster package)? After a few tests, it appears that intersect is a 
little bit faster. Moreover, intersect automatically calculates the 
associated dataframe, while gIntersection leaves the user making it.

Thanks for your awer(s).

Jean-Luc
#
Jean-Luc.

It is as you say, intersect returns Spatial*DataFrame objects whereas
gIntersect does not the DataFrame bits.
This pattern is also true for raster functions aggregate, union,
erase, cover and crop (see section XIV in ?'raster-package') which all
have their analogues in rgeos that they build on.
intersect uses gIntersection so it should not be faster.

Robert
On Thu, May 14, 2015 at 2:48 PM, Jean-Luc Dupouey <dupouey at nancy.inra.fr> wrote: