How can I find objects with the same tag next to each other via overpass-turbo?

For the purpose of quality checks I would like to find objects that are close to each other that use the same tag, in this example amenity=fire_station. So I basically need the overpass-turbo translation for:

Show me every object that is tagged amenity=fire_station if there is another object tagged amenity=fire_station within a 100 meter radius.

How can I do this? I think the solution will probably include nwr["amenity"="fire_station"](around:100); but I can’t get it working.

Disclaimer

I read somewhere that the practice of tagging every building of a fire station with amenity=fire_station is normal in some areas but I do not remember where I found that. The question whether that is good practice or not is not the topic here. I just want to investigate the situation for now.

1 Like

This should do the trick.

nwr[amenity=fire_station]({{bbox}})->.a;
foreach.a->.elem(
  nwr.a(around.elem:50);
  (._; - .elem;);
  out meta;
);

Modified from this example in the wiki.

1 Like

Thanks a lot for your help. Unfortunatly your code only finds nodes for some reason and not ways. See here for overpass-turbo.

With the help of the auto-repair-function I got this working:

[out:json];
nwr["amenity"="fire_station"]({{bbox}})->.a;
foreach.a->.elem(
  nwr.a(around.elem:100);
  (._; - .elem;);
  (._;>;);
  out geom;
);

See here for overpass-turbo. I don’t realy understand the “(._;>;);” added by the auto-repair but now it is working as expected. Thanks again!

A nice bonus would be a working out count;-statement. For some reason the counted numbers I get are not what I would expect.

1 Like

Glad you got it working.

I’m on mobile rn and it’s a bit of a pain, sorry I didn’t catch that node vs ways issue.

re your disclaimer: I think one amenity=fire_station is correct. Individual buildings may be tagged as building=fire_station

Unfortunatly the code still does not work. I tried creating a MapRoulette-Challenge containing all possible dublicats of amenity=fire_station in South Australia (AU-SA). I used this code:

area["ISO3166-2"="AU-SA"];
nwr["amenity"="fire_station"](area)->.a;
foreach.a->.elem(
  nwr.a(around.elem:100);
  (._; - .elem;);
  (._;>;);
  out geom;
);

It gave me these Challenges:

The overpass-querry seems to show every relevant way but also every node of the way. So for 2 buidlings tagged amenity=fire_station I get 10 challenges. Additionally there is one node with amenity=fire_station in one of the buidlings. I would have expected three challenges, one for each occurance of amenity=fire_station.

Can someone fix the overpass-query for me?

For some reason removing the “(._;>;);” that got added by the auto-repair did the trick. :person_facepalming:
So my code now is:

area["ISO3166-2"="AU-SA"];
nwr["amenity"="fire_station"](area)->.a;
foreach.a->.elem(
  nwr.a(around.elem:100);
  (._; - .elem;);
  out geom;
);

The only thing I am still missing is a working out count; to give me the total number of hits.