eteb3
October 14, 2019, 5:19pm
#1
This is a theoretical question prior to speaking to a parish council about them using OSM.
Is it possible to write an overpass query that will find X within an administrative area?
e.g., could we find ‘grit bins in Sutton ’?
And if a parish council wanted to tag its own assets, could it add the tag ‘operator=suttonpc’ to find all of them easily?
You might want to try typing “grit bin” in Sutton in the wizard on overpass-turbo.eu .
Another thing you might want to try is reading the documentation on https://wiki.openstreetmap.org/wiki/Overpass_turbo/Wizard .
eteb3
October 14, 2019, 6:13pm
#3
Wow, thanks, I had no idea it would be that easy: I thought the only area filter was the bounding box.
It works great except that it takes the Sutton to mean the London Borough of Sutton, rather than Sutton the civil parish in Peterborough City Council area.
I’ve just dug up the guidance at https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#By_area_.28area.29 but can’t make easy sense of it: I assume there must be a way to specify the other Sutton?
eteb3
October 14, 2019, 6:24pm
#4
Great, thank you for the pointer to the documentation.
My solution, for anyone else finding this: put ‘Sutton’ into the search box on openstreetmap.org
Copy the full address of the particular Sutton you want, e.g., Sutton, City of Peterborough, East of England, England, PE5 7XA, United Kingdom
Put it into the wizard with " " around it, as described here https://wiki.openstreetmap.org/wiki/Overpass_turbo/Wizard#Location_Filters
so this query is
“grit bin” in “Sutton, City of Peterborough, East of England, England, PE5 7XA, United Kingdom”
Another solution, using the “admin level” is this code: (paste the following into overpass turbo) or use this link .
[out:json];
area
["admin_level"="10"]
["name"="Sutton"];
out body;
node
["amenity"="grit_bin"]
(area);
out body qt;
>;
out skel qt;
eteb3
October 23, 2019, 2:58pm
#6
Thanks for that: it was useful. While using it I’ve found that there are at least three places called “Sutton” at admin level=10 in the UK.
So rather than use “Sutton” it’s possible to use the ref:gss=* number, which appears to be a unique identifier for a particular admin area.
eteb3
October 23, 2019, 4:08pm
#7
Update: but that number can change over time if the boundary is redefined in law. So usefulness is limited over time.
eteb3
October 23, 2019, 4:35pm
#8
Update: but that number can change over time if the boundary is redefined in law. So usefulness is limited over time.
A better solution is from DaveF on the Talk-GB list:
As you want a specific area, the way I do it is to get the relation boundary’s id & add it to 3600000000 (which is the start of the databases numbering for relations so they don’t overlap with ways & nodes).
area(3601608485); // Sutton
//node[amenity=grit_bin]
nwr[building](area);
out meta center;