multiple nearby Location by coordinates: finding multiple nearby POIs

dear comunity,

hope youre all right and everything goes well at your hometown. Hope youre well!!

the question of today: multiple nearby Location by coordinates: finding multiple nearby POIs

first of all - merry christmas.

the question of today: multiple nearby Location by coordinates: finding multiple nearby POIs from current location in OpenStreetMap

we can use Overpass API to search for nearby POIs. We can perform queries against Overpass API and display them as overlays on an OSM map: The question is: Is there any API for OpenStreetMap which allows me to obtain a list of (multiple) POIs within a certain distance (e.g. 50 kilometers) from a reference location: we take for example schools and hospitals.

what is wanted: I want to query openstreetmaps api for amenitys near a specified city - lets Say München (/Munich) which is part of Bavaria (Bayern) in Germany. I want to find all hospitals and schools near Munich (München), within a radius of 50 km.

some basics: The openstreetmaps API Documentation doesn’t say some thing that might help here:

[out:csv(::id,::type,::lon, ::lat, "name","addr:postcode","addr:city","addr:street","addr:housenumber","contact:website"," contact:email=*")][timeout:600];
    area[name="Münschen"];
    nwr(around:10000)["amenity"="hospital"];
    nwr(around:10000)["amenity"="school"];
    
    out center;

but this does not work - unfortunatly:

For this kind of request, we generally are working with Overpass API ( https://wiki.openstreetmap.org/wiki/Overpass_API ), which is a read-only API that’s designed for such queries (unlike the main OSM API, also known as Editing API, which is mostly useful for contributing to OSM).

Overpass API supports an great and very very helpful around filter ( https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Relative_to_other_elements_.28around.29 )

**our example **– hospitals in a 50 km radius around Munich – might look like this.

(This is a link to Overpass Turbo, which is a frontend that lets 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, we’ll need to provide either the coordinates or OSM element(s) we want to filter around.)

for our example- we take München:


    (
      node["amenity"="hospital"](around:50000,{{geocodeCoords:München}});
      way["amenity"="hospital"](around:50000,{{geocodeCoords:München}});
      relation["amenity"="hospital"](around:50000,{{geocodeCoords:München}});
    );
    out;
    >;
    out;

but why does this not work:



    [out:csv(::id,::type,::lon, ::lat, "name","addr:postcode","addr:city","addr:street","addr:housenumber","contact:website"," contact:email=*")][timeout:600];
    area[name="Münschen"];
    nwr(around:10000)["amenity"="hospital"];
    nwr(around:10000)["amenity"="school"];
    
    out center;

  • well how to retrieve the data: how to retrieve the data out of a nearby search - with two entities - shools and hospitals.

To build a query, we need to know which OpenStreetMap tags correspond to the feature types were actually interested in. The OpenStreetMap wiki provides documentation for most commonly used tags, e.g. amenity=hospital in this example. And yes: besides hospital, we use schools as a second tag. We can use Overpass API to search for nearby POIs. And yes - guess that we need to perform queries against Overpass API and display them as overlays on an OSM map.

**Overpass API **supports an around filter( https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Relative_to_other_elements_.28around.29 )

The around filter selects all elements within a certain radius around the elements in the input set. If you provide coordinates, then these coordinates are used instead of the input set. The input set can be changed with an adapted prefix notation. As for all filters, the result set is specified by the whole statement, not the individual filter. A radius of 0 can be used for a way intersection test on outer/inner points. Syntax: It consists of an opening parenthesis. Then follows the keyword around. Then follows optionally an input set declaration. Then follows a single floating point number that denotes the radius in meters. The filter either ends with a closing parenthesis or is followed by two comma separated floating point numbers indicating latitude and longitude and then finally a closing parenthesis.

amenity=hospital is used for hospitals :
https://wiki.openstreetmap.org/wiki/Tag:amenity%3Dhospital: amenity=hospital is used for hospitals, i.e. institutions for health care providing treatment by specialised staff and equipment, and typically providing nursing care for longer-term patient stays. In contrast, a medical centre with doctors for outpatient care only should be tagged amenity=clinic, and an individual doctor’s office as amenity=doctors.

the question:- well how to retrieve the data: how to retrieve the data out of a nearby search - with two entities - shools and hospitals.