I'm trying to determine if a specific gps coordinate is within a gps spatial polygon.

My gps coordinate is being outputted from the geocode function from the ggmap library and the spatial polygons are being read from a GeoJSON file using readOGR.

So far I've found pieces of what I'm looking for in the sp and maptools library but no specific functions...any suggestions ?

  • 2
    The high-level ?over or the low-level ?point.in.polygon is what you are after. – mdsumner Sep 17 '15 at 20:30
  • 2
    or over. data wld be nice tho – hrbrmstr Sep 18 '15 at 1:09
  • In case you're dealing with projected coordinate systems, gIntersection from the rgeos package should work as well. – fdetsch Sep 18 '15 at 7:24

I had a similar problem that I solved using the over() function from the sp package. The key was making sure that both the list of GPS points and the loaded shapefile are in the same CRS:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.