An area ID in Overpass is the OSM relation ID + 3600000000
This information is kind of buried in the Overpass API wiki page documenting the available filters: https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29
The OSM relation ID can be seen in two places:
- Visit https://www.openstreetmap.org and search for the city
- Click on its entry and you will be taken to a
https://www.openstreetmap.org/relation/SOME_NUMBER_HERE
page - The relation ID is in the URL as "SOME_NUMBER_HERE" in the bullet point above
- The relation ID will also be in parentheses next to the city name in the left column
This query will return all of the nodes for any street that has any node within the area boundary:
[timeout:900][out:json];
area(3600000000 + OSM_RELATION_ID);
(
way(area)
['name']
['highway']
['highway' !~ 'path']
['highway' !~ 'steps']
['highway' !~ 'motorway']
['highway' !~ 'motorway_link']
['highway' !~ 'raceway']
['highway' !~ 'bridleway']
['highway' !~ 'proposed']
['highway' !~ 'construction']
['highway' !~ 'elevator']
['highway' !~ 'bus_guideway']
['highway' !~ 'footway']
['highway' !~ 'cycleway']
['foot' !~ 'no']
['access' !~ 'private']
['access' !~ 'no'];
);
(._;>;);
out;
This query will return only the nodes within the area for any street that has any node within the area boundary:
[timeout:900][out:json];
area(3600251075)->.a;
(
way(area.a)
['name']
['highway']
['highway' !~ 'path']
['highway' !~ 'steps']
['highway' !~ 'motorway']
['highway' !~ 'motorway_link']
['highway' !~ 'raceway']
['highway' !~ 'bridleway']
['highway' !~ 'proposed']
['highway' !~ 'construction']
['highway' !~ 'elevator']
['highway' !~ 'bus_guideway']
['highway' !~ 'footway']
['highway' !~ 'cycleway']
['foot' !~ 'no']
['access' !~ 'private']
['access' !~ 'no'];
node(w)(area.a);
);
out;
Awesome script! If I could ask - could You provided a hint how to remake this into country->cities from cities->streets?