Identifying overlapping polygons
I am still feeling my way around the "protocol" of this list serve, so I do not want to clobber the archives with unneccessary communication. However, I am compelled to say thanks for the quick turn around and the extremely helpful suggestions from Greg and Roger. Thanks and I will let you know how it ends up! -----Original Message----- From: Greg Snow [mailto:Greg.Snow at intermountainmail.org] Sent: Friday, February 09, 2007 4:27 PM To: Roger.Bivand at nhh.no; Andrew Niccolai Cc: r-sig-geo at stat.math.ethz.ch Subject: RE: [R-sig-Geo] Identifying overlapping polygons 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. 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