Skip to content
Prev 21274 / 29559 Next

Create SpatialPolygonsDataFrame indicating the polygons in a single source SpatialPolygonsDataFrame that overlap with the new polygons?

On Fri, 4 Jul 2014, nevil amos wrote:

            
Yes, use the rgeos package. In fact your problem isn't very well formed, 
because the outcome is 9 intersections, 3 of which are equal:

gII <- gIntersection(SDF, SDF, byid=c(TRUE, TRUE))
gEquals(gII, gII, byid=TRUE)

Retrieve the IDs from the row.names() of GII, but you'll need to copy back 
the off-diagonal equalities.

You can set up gIntersection() for large n by first using gIntersects(..., 
returnDense=FALSE) to return only an n-list of predicate TRUE indices, or 
query a binary STRtree to generate a similar list. See for example 
suggestions in:

http://spatial.nhh.no/misc/ogrs14/ogrs140612.zip

in ogrs_140612.R (there line/polygon intersections)

This should put you on a feasible track, I hope.

Roger