dil_bert Posted December 25, 2020 Share Posted December 25, 2020 hope youre all right and everything goes well at your hometown. Hope youre well!! 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. Quote Link to comment Share on other sites More sharing options...
dil_bert Posted December 25, 2020 Author Share Posted December 25, 2020 at the first glance all that ideas look very interesting. . i found some ideas to do the job - also like so: [out:csv(::id,::type,::lon, ::lat, "name","addr:postcode","addr:city","addr:street","addr:housenumber","contact:website"," contact:email=*")][timeout:600]; rel[boundary=administrative][admin_level=6][name="München"] -> .city; (nwr[amenity=hospital](around.city:2000); nwr[amenity=school](around.city:2000);); out center; @id @type @lon @lat name addr:postcode addr:city addr:street addr:housenumber contact:website contact:email=* 60234799 node 11.5618175 48.1322485 Medizinische Klinik 80336 München Ziemssenstraße 1 60235532 node 11.5605247 48.1310014 "Mund-, Kiefer-, Gesichtschirurgie" 80337 München Lindwurmstraße 2a 60235905 node 11.5592053 48.1302821 Dr. von Haunersches Kinderspital 80337 München Lindwurmstraße 4 60237053 node 11.5581961 48.1316760 Poliklinik Zahnärztliche Prothetik 80336 München Goethestraße 70 60237068 node 11.5581921 48.1313295 Poliklinik Zahnerhaltung und Parodontologie 80336 München Goethestraße 70 60237323 node 11.5581778 48.1309824 Poliklinik Kieferorthopädie 80336 München Goethestraße 70 60347733 node 11.5919091 48.1313181 Münchner Volkshochschule 199521374 node 11.3744767 48.1874144 Bernhard-Rößner-Grundschule Gröbenzell 207230074 node 11.3616774 48.1785758 Grundschule am Gerner Platz 82178 Puchheim Gerner Platz 2 207231287 node 11.3614999 48.1791463 Mittelschule Puchheim 82178 Puchheim Lagerstraße 26 257005653 node 11.5685660 48.2073080 Balthasar-Neumann-Realschule 269510209 node 11.4219190 48.1179807 Wolfartklinik 82166 Gräfelfing Waldstraße 7 271226325 node 11.5619132 48.1409559 Medizinischer Bereitschaftsdienst Prielmayerstraße 3 274617211 node 11.6000672 48.1343476 Schule zur Lernförderung 81675 München Kirchenstraße 13 287819214 node 11.4237356 48.1353946 Förderschule und Heilpädagogische Tagesstätte 81249 München Köferinger Straße 20 295434645 node 11.6410472 48.1924715 VHS Unterföhring 85774 Unterföhring Münchner Straße 72 300673921 node 11.6390371 48.0907877 Volkshochschule München Perlach-Süd 81739 München Max-Reinhardt-Weg 29 312793352 node 11.5815046 48.1322045 Schulverbund München 80469 München Kohlstraße 5 332544444 node 11.5602074 48.1420984 Münchner Schmink und Kosmetikschule 332617267 node 11.5649428 48.1347820 Isar Medizin Zentrum 80331 München Sonnenstraße 24 338723406 node 11.4742575 48.2083018 Waldklassenzimmer 342309527 node 11.5689469 48.2065680 Grundschule an der Hugo-Wolf-Straße 358171049 node 11.3574259 48.1813010 Realschule Puchheim 82178 Puchheim Bürgermeister-Ertl-Straße 9 439254427 node 11.5644958 48.1287555 Klinik Thalkirchner Straße 80337 München Thalkirchner Straße 48 443898649 node 11.6623555 48.0769996 Volkshochschule 539112865 node 11.6693667 48.2184675 Grundschule an der Camerloherstraße 85737 Ismaning Camerloherstraße 20 618659788 node 11.5596871 48.1332364 Institut für Rechtsmedizin 80336 München Nußbaumstraße 26 619332417 node 11.6639514 48.0764239 Musikschule Neubiberg 656248222 node 11.5820112 48.1247064 Grundschule am Mariahilfplatz 81541 München Mariahilfplatz 18 ... and so forth and so forth.. many many thanks you guy that you run this forum here . as allways it is so helpful and i get many many ideas out of this forum thoughts are very helpful have a great day greetings :bigsmile: Quote Link to comment Share on other sites More sharing options...
dil_bert Posted December 26, 2020 Author Share Posted December 26, 2020 (edited) at the first glance all that ideas look very interesting. - many many thanks. i found some ideas to do the job - also like so: [out:csv(::id,::type,::lon, ::lat, "name","addr:postcode","addr:city","addr:street","addr:housenumber","contact:website"," contact:email=*")][timeout:600]; rel[boundary=administrative][admin_level=6][name="München"] -> .city; (nwr[amenity=hospital](around.city:2000); nwr[amenity=school](around.city:2000);)/>; out center; see the output @id @type @lon @lat name addr:postcode addr:city addr:street addr:housenumber contact:website contact:email=* 60234799 node 11.5618175 48.1322485 Medizinische Klinik 80336 München Ziemssenstraße 1 60235532 node 11.5605247 48.1310014 "Mund-, Kiefer-, Gesichtschirurgie" 80337 München Lindwurmstraße 2a 60235905 node 11.5592053 48.1302821 Dr. von Haunersches Kinderspital 80337 München Lindwurmstraße 4 60237053 node 11.5581961 48.1316760 Poliklinik Zahnärztliche Prothetik 80336 München Goethestraße 70 60237068 node 11.5581921 48.1313295 Poliklinik Zahnerhaltung und Parodontologie 80336 München Goethestraße 70 60237323 node 11.5581778 48.1309824 Poliklinik Kieferorthopädie 80336 München Goethestraße 70 60347733 node 11.5919091 48.1313181 Münchner Volkshochschule 199521374 node 11.3744767 48.1874144 Bernhard-Rößner-Grundschule Gröbenzell 207230074 node 11.3616774 48.1785758 Grundschule am Gerner Platz 82178 Puchheim Gerner Platz 2 207231287 node 11.3614999 48.1791463 Mittelschule Puchheim 82178 Puchheim Lagerstraße 26 257005653 node 11.5685660 48.2073080 Balthasar-Neumann-Realschule 269510209 node 11.4219190 48.1179807 Wolfartklinik 82166 Gräfelfing Waldstraße 7 271226325 node 11.5619132 48.1409559 Medizinischer Bereitschaftsdienst Prielmayerstraße 3 274617211 node 11.6000672 48.1343476 Schule zur Lernförderung 81675 München Kirchenstraße 13 287819214 node 11.4237356 48.1353946 Förderschule und Heilpädagogische Tagesstätte 81249 München Köferinger Straße 20 295434645 node 11.6410472 48.1924715 VHS Unterföhring 85774 Unterföhring Münchner Straße 72 300673921 node 11.6390371 48.0907877 Volkshochschule München Perlach-Süd 81739 München Max-Reinhardt-Weg 29 312793352 node 11.5815046 48.1322045 Schulverbund München 80469 München Kohlstraße 5 332544444 node 11.5602074 48.1420984 Münchner Schmink und Kosmetikschule 332617267 node 11.5649428 48.1347820 Isar Medizin Zentrum 80331 München Sonnenstraße 24 338723406 node 11.4742575 48.2083018 Waldklassenzimmer 342309527 node 11.5689469 48.2065680 Grundschule an der Hugo-Wolf-Straße 358171049 node 11.3574259 48.1813010 Realschule Puchheim 82178 Puchheim Bürgermeister-Ertl-Straße 9 439254427 node 11.5644958 48.1287555 Klinik Thalkirchner Straße 80337 München Thalkirchner Straße 48 443898649 node 11.6623555 48.0769996 Volkshochschule 539112865 node 11.6693667 48.2184675 Grundschule an der Camerloherstraße 85737 Ismaning Camerloherstraße 20 618659788 node 11.5596871 48.1332364 Institut für Rechtsmedizin 80336 München Nußbaumstraße 26 619332417 node 11.6639514 48.0764239 Musikschule Neubiberg 656248222 node 11.5820112 48.1247064 Grundschule am Mariahilfplatz 81541 München Mariahilfplatz 18 ... and so forth and so forth.. mani. as allways this forum is so greta: i love it. the ideas here very helpful. have a great day greetings :bigsmile:/> Edited December 26, 2020 by dil_bert Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.