This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Searching using bounding box

1

I'm trying to obtain list of supermarkets in Santa Clara in CA, USA. I've crafted following query:

area[name="California"]->.state;
area[name="Santa Clara"]->.city;
node(area.state)(area.city)[shop=supermarket];
out;

The problem is with cases that are inside Santa Clara (city) bounding box but doesn't have "city" or "state" values in their meta data.

Is there a way to search using bounding box instead of city name?

asked 18 Jun '22, 08:18

sebap123's gravatar image

sebap123
46225
accept rate: 0%


One Answer:

1

There appears to be two problems: 1. You were asking it to return just nodes. 'nwr' (nodes, ways, relations) returns all objects. 2. The out; statement returns all entities (click the Data tab), but only renders nodes. Never been sure if this is a bug or 'Expected behaviour'

area[name="California"]->.state;
area[name="Santa Clara"]->.city;
nwr(area.state)(area.city)[shop=supermarket];
out center;

If you're going to make repeated use of the routine, I've found it more efficient to directly use the city's id:

area(3602221647);
nwr[shop=supermarket](area);
out center;

Also, take a look at my similar answer which gives you multiple options to do the same thing.

https://help.openstreetmap.org/questions/84723/use-polygon-for-an-overpass-turbo-query

answered 18 Jun '22, 13:42

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

edited 18 Jun '22, 23:20

Source code available on GitHub .