Search code examples
openstreetmapoverpass-api

Overpass API store name around another store


I'm trying to use the Overpass API through overpass turbo to find stores that are around other stores e.g. Walmart within 100m of Taco Bell within the map area.

I'm very new to overpass so I'm mostly relying on the wizard to generate the queries for me. I've had a hard time finding good resources to learn how to query properly, at least the correct syntax.

I'm basically trying searches like this: shop=* and name="Walmart Supercenter" around shop=* and name="Taco Bell"

any help is greatly appreciated.


Solution

  • Try this:

    [out:json][timeout:25];
    
    nwr["shop"]["name"~"Taco Bell",i]({{bbox}}) -> .foo;
    nwr["shop"]["name"~"Walmart Supercenter",i](around.foo:100);
    
    // print results
    out body;
    >;
    out skel qt;
    

    It searches for shops with the name "Taco Bell" and stores it in a set called foo. Then it searches for shops with the name "Walmart Supercenter" within a distance of 100 meters around the elements in set foo.

    I've used a case-insensitive regular expression match for the name in case the name slightly varies.