OpenStreetMap – How to Fetch Data with Overpass Turbo Query by Name and Coordinates

geocodingopenstreetmapoverpass-apioverpass-turbo

I have a list of tourist attractions, each with the name of the attraction, its address, and its coordinates (lat/long).

How can I query Overpass Turbo to accurately return data about these attractions?

For example, I've tried this query for the CN Tower in Toronto:

[out:json];
way(around:100,43.6425662,-79.3870568)[~"name"~"cn tower",i];
out;

And it returns data about the CN Tower but it also returns data about the CN Tower ticket kiosk, which I don't want.

Is there anything I can/should do to modify my query to be a little more specific in what I'm looking for?

Best Answer

To query a specific attraction like the CN Tower in Toronto, just find a tag combination that is sufficient to only query the single object you want data for. man_made=tower is one of the solutions here.

[out:json][timeout:25];
way[man_made=tower][name="CN Tower"];
out geom;

With out geom; you get the geometry returned in the "Map" tab, as well as all data including coordinates in the "Data" tab.

To query all the tourist attractions at once, you certainly won't find a very simple query in your case, as the tourist attractions have very different tags and types. Just use a filter by Geocode area for Toronto, then add the objects you need as single query parts. As long as they are of the same type, you can search for all names using name~"name 1|name 2".

[out:json][timeout:25];
{{geocodeArea:Toronto}}->.a;
(
  nwr[tourism=attraction][name="CN Tower"](area.a);
  nwr[tourism=aquarium][name="Ripley's Aquarium of Canada"](area.a);
  nwr[leisure=park][name="High Park"](area.a);
);
out geom;

To find all the tourist spots in Toronto, you could use

[out:json][timeout:25];
{{geocodeArea:Toronto}};
nwr[tourism~"attraction|aquarium|museum|zoo"](area);
out geom;

and add additional values from the list provided here in the OSM Wiki. However, this does not include features like parks for example.

Related Question