Sithys
Sithys

Reputation: 3793

Query Openstreetmap for specific amenity

I want to query openstreetmaps api for amenitys near a specified city / coords. So something like

Find all hospitals near denver, within a radius of 50km. The openstreetmaps API Documentation doesn't say anything about amenitys or i didn't found that.

Is this possible via REST and if yes, how?

Upvotes: 4

Views: 2506

Answers (1)

Tordanik
Tordanik

Reputation: 1353

For this kind of request, you'll likely want to use Overpass API, which is a read-only API that's designed for queries (unlike the main OSM API, also known as Editing API, which is mostly useful for contributing to OSM).

Overpass API supports an around filter.

Your example – hospitals in a 50 km radius around Denver – might look like this. (This is a link to Overpass Turbo, which is a frontend that helps with building and testing Overpass API queries. Note that the Geocoding in the example is a convenience feature of Overpass Turbo. For regular Overpass API queries, you'll need to provide either the coordinates or OSM element(s) you want to filter around.)

To build your query, you will want to know which OpenStreetMap tags correspond to the feature types you're interested in. The OpenStreetMap wiki provides documentation for most commonly used tags, e.g. amenity=hospital in this example.

Upvotes: 13

Related Questions