Querying distance of amenities to a precise coordinate pair

Hello OSM,

I’m working on a project where I have distinct coordinate pairs of residential locations in a database. I’d like to determine the proximity of other amenities (hospital, school, fire station, police station, grocery store) to each of these locations via a API call using python. Can someone point me to some documentation of where I can learn more about this use case? Also where can I signup for an API key?

Thanks,

MK

The general answer is “stick the data in a database that supports spatial queries on it and then use native database queries”. The database part of this will help with the first part, even if you’re not interested in rendering a map.

However, you say that you’ve already got the data in a database, so you may be able to add spatial support to that (e.g. Postgis to Postgresql) and do queries straight away. Presumably the question relates to OSM in that your “residential locations” aren’t in OSM but the “other amenities” area?

OSM does not have an API key. You can just download the data and subject to the license do what you like with it.

OSM itself is a database project and therefor does not offer any apis that allow you to query data in this way. There are however many apis using OSM data.

There is no api I am aware of that allows you to do this in one call. You could potentially use overpass and the around: query with the input coordinates and then output the center coordinates for each element. You would then have to compute the distance manually on your end using the haversine formula.