[R-sig-Geo] Finding the county shapefile polygon closest to a long-lat position
p.hiemstra at geo.uu.nl
Thu May 21 23:23:44 CEST 2009
If you have your data loaded into R as spatial objects, you can find in
which polygons the points fall using the overlay() function from the
sp-pacakge. See the documentation there. I'm not sure what to do if the
point falls outside a polygon and you need the nearest.
BRWIN338 at aol.com schreef:
> I have a large number of long-lat locations dispersed over the US and need
> to identify which US county that each point is located in (or nearest to).
> After reading the past posts and Roger's book, I have been able to use the
> overlay function
> to identify the appropriate counties for the set of locations
> with long-lats lying within or on a polygon boundary. However, due to
> longlat precision errors (I am assuming), some of the points lie outside
> all of
> my shapefile's county polygon boundaries.
> Is there an R function similar to "overlay" that I could use to find which
> county polygon is closest to each of my longlat points that do not lie
> within the shapefile's polygons? I have spent quite a bit of time
> and browsing past list discussions and can seem to find my answer.
> My apologies if I have missed an obvious answer.
> **************Huge savings on HDTVs from Dell.com!
> [[alternative HTML version deleted]]
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 274 3113 Mon-Tue
Phone: +3130 253 5773 Wed-Fri
More information about the R-sig-Geo