Overpass query using administrative boundaries as the bounding 'box'?

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.

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?

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;

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.

Update: but that number can change over time if the boundary is redefined in law. So usefulness is limited over time.

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: