[R-sig-Geo] Finding the county shapefile polygon closest to a long-lat position

Paul Hiemstra p.hiemstra at geo.uu.nl
Thu May 21 23:23:44 CEST 2009


Hi,

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.

cheers,
Paul

BRWIN338 at aol.com schreef:
> Greetings
> 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  
> searching 
> and browsing past list discussions and can seem  to find my  answer.
>
> My apologies if I have missed an obvious  answer.
>
> Joe          
>
>
> **************Huge savings on HDTVs from Dell.com! 
> (http://pr.atwola.com/promoclk/100126575x1221836042x1201399880/aol?redir=http:%2F%2Fad.doubleclick.ne
> t%2Fclk%3B215073686%3B37034322%3Bb)
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>   


-- 
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone:  +3130 274 3113 Mon-Tue
Phone:  +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul



More information about the R-sig-Geo mailing list