0

I need to find the closest point on a road to a external point. I need to do it without downloading the data (I don't know if this is possible in Google Maps) nor using PostgreSQL. I know some Python wrappers to Overpass for using OpenStreetMap, where is easy to use the function 'around', which is I need. But is possible to do the same for the free API of Google Maps?

I've asked a similar question in Getting closest point on road to point in OpenStreetMap using Python?, but with OpenStreetMap. What about Google Maps?

  • What do you mean by data? The background data provided by Google (geocoding, routing, etc.) or do you have your own files? – BritishSteel Apr 4 '16 at 11:08
  • 1
    Sorry for my bad explanation. I known (and I'm newbie in this kind of tasks) that I can download the OpenStreetMap 'data' (vector information of reads, etc.), then convert it to a PostgreSQL database via osm2pgsql and then make my queries as a local user. But I need to do the queries via web, task that I can do via Overpass and some of its Python wrapper. Now I need to do the same in Google Maps and again I need to do it via web, without download any data nor transforming it to any database – jgpallero Apr 4 '16 at 11:30
1

Since you downloaded the OSM data I would suggest you convert it to GeoJSON, so you can work with Turf.js, which accepts GeoJSON as input data.

To convert data to GeoJSON you can work with different tools, such as geojson.io or QGIS.

Once everything is in GeoJSON you can use turf.nearest (documentation and example). Since you are probably testing a point against a line you should have a look at turf.point-on-line. In case you are working with polygons, you should check out the documentation and example of turf.explode, so you can actually access individual vertices from that polygon.

Turf.js is very easy to use and it works with any mapping library, as long as it supports GeoJSON. So, not a problem at all with Google Maps.

  • Thank you for your answer, but I need to work without downloading any data – jgpallero Apr 4 '16 at 12:30
  • I'm working with GPX files and I need to adjust the recorded GPS path to the real ways, so this is the reason because I need to extract the nearest point in a road to my GPS point, which in OpenStreetMaps via the Overpass interface can be done via the 'around' query – jgpallero Apr 4 '16 at 12:42

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.