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

Filtering on key only if key exists using overpass query language

0

I want to match bridges which are considered metallic or unknown.

I tried this:

area[name="Australia"]->.a;
way(area.a)
[man_made=bridge]
[bridge!=viaduct]
["bridge:structure"!=humpback]
[material~metal]
[material~steel]
[material~reinforced_concrete]
["bridge:material"~steel]
["bridge:material"~metal];
out geom;

But it this ignores bridges that don't have the material or "bridge:material" key. Looking at the overpass docs doesn't mention anyway to match on a key only if that key exists.

asked 05 Feb '17, 09:46

CMCDragonkai's gravatar image

CMCDragonkai
21112
accept rate: 0%

I think you should use the union operator ( ) and search for bridges without bridge:material on one hand with [!"bridge:material"] and the ones you are looking for above.

(05 Feb '17, 11:22) escada

Source code available on GitHub .