[R-sig-Geo] Identifying overlapping polygons

Roger Bivand Roger.Bivand at nhh.no
Fri Feb 9 22:52:52 CET 2007


On Fri, 9 Feb 2007 White.Denis at epamail.epa.gov wrote:

> r-sig-geo-bounces at stat.math.ethz.ch wrote on 2007-02-09 13:27:13:
> 
> > Andrew,
> >
> > Util the functionality is programmed in, here is a quick approximation
> > to what you want:
> >
> > 1. generate a large number of random (or gridded) points within the
> > polygon of interest in the first object (sample.polygon function in
> > package sp).
> > 2. use the overlay function in the sp package to find out which
> polygons
> > in object 2 the random points fall into.  You know these overlap.
> >
> > If there is a polygon in object 1 that only slightly overlaps a
> polygon
> > in object 2, then you are unlikely to detect that using this method,
> but
> > your statement about controlling the "Partial" indicates that this may
> > be a good thing.
> >
> > Turning this around and generating the points from object 2 and seeing
> > which polygon in object 1 they are in will tell you if the polygon in
> > object 2 is completely overlapped by the one in 1.
> 
> An interesting suggestion, emulating the old manual way of computing the
> area of a polygon, if you were to use a grid of points whose surrounding
> areas (Voronoi polygons) were all identical.  To deal with "partial",
> choose the spacing of points (hence areas of Voronoi polygons) to be a
> compromise between a desired resolution and computation time, depending
> on how many of these comparisons you need to make.

Yes, with a good choice of resolution it will get you pretty close without 
any coding, certainly close enough to know whether coding is worth the 
trouble. For a medium resolution grid and running through lunch breaks or 
overnight, it could be all you need. The code in the GE_overlay() function 
in maptools might show how to build an input SpatialGrid to overlay - but 
you'll need to check to use a bounding box to include both sets of 
polygons.

Roger

> 
> >
> > Hope this helps,
> >
> > --
> > Gregory (Greg) L. Snow Ph.D.
> > Statistical Data Center
> > Intermountain Healthcare
> > greg.snow at intermountainmail.org
> > (801) 408-8111
> >
> >
> >
> > > -----Original Message-----
> > > From: r-sig-geo-bounces at stat.math.ethz.ch
> > > [mailto:r-sig-geo-bounces at stat.math.ethz.ch] On Behalf Of Roger
> Bivand
> > > Sent: Friday, February 09, 2007 12:56 PM
> > > To: Andrew Niccolai
> > > Cc: r-sig-geo at stat.math.ethz.ch
> > > Subject: Re: [R-sig-Geo] Identifying overlapping polygons
> > >
> > > On Fri, 9 Feb 2007, Andrew Niccolai wrote:
> > >
> > > > Hi.  I am relatively new to Spatial-R.  I have two objects that
> are
> > > > both SpatialPolygonsDataFrame classes.  One is comprised of
> > > polygons
> > > > from a section of a segmented image and the other is essentially
> > > > circular polygons representing the potential areas that the
> > > crowns of
> > > > known tree locations might cover.  I would like to identify every
> > > > polygon from the first object (image segmentation polys) that
> > > > completely are even partially (hopefully I can control the
> > > "partial"
> > > > threshold) falls within any given polygon from the second object
> > > > (crown areas).  In ArcGIS this can be accomplished using
> > > the Identity
> > > > application under ArcToolbox.  I was hoping to accomplish
> > > the same feats in R.  Any help would be greatly appreciated!!
> > >
> > > This is not present yet, but not impossible. If you look in
> > > the code of the unionSpatialPolygons() function in the
> > > maptools package, you will see that it uses functions in the
> > > gpclib package. Using similar ideas to examine either all n
> > > by m intersections, or a clever subset by looking at bounding
> > > box intersections first, it ought to be feasible. You'll need
> > > to be prepared to code it, though.
> > >
> > > Roger
> > >
> > > >
> > > > Andrew Niccolai
> > > > Doctoral Candidate
> > > > Yale School of Forestry
> > > >
> > > > _______________________________________________
> > > > R-sig-Geo mailing list
> > > > R-sig-Geo at stat.math.ethz.ch
> > > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > > >
> > >
> > > --
> > > Roger Bivand
> > > Economic Geography Section, Department of Economics,
> > > Norwegian School of Economics and Business Administration,
> > > Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55;
> > > fax +47 55 95 95 43
> > > e-mail: Roger.Bivand at nhh.no
> > >
> > > _______________________________________________
> > > R-sig-Geo mailing list
> > > R-sig-Geo at stat.math.ethz.ch
> > > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> > >
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo at stat.math.ethz.ch
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-sig-Geo mailing list