OpenStreetMap Forum

The Free Wiki World Map

You are not logged in.

#1 2019-04-21 11:41:48

ghowen
Member
Registered: 2018-11-25
Posts: 5

Overpass "not equal" operator for values

During development I came across a peculiarity that I frankly don't understand:

When creating an overpass query with the not equal operator for a value, it matches all elements that are tagged with the respective key and but not this value (so far so good) AND all elements that are not tagged with this key.

According to https://wiki.openstreetmap.org/wiki/Ove … uage_Guide this is intended behaviour.

Now, if I wanted all elements not tagged with a key, I would intuitively use the "not equals" operator on the key, which is supported and does work.

So does anyone know why not equalling a value also includes elements not tagged with the key of this comparison?

Thanks!

Offline

#2 2019-04-21 12:10:38

GerdP
Member
Registered: 2015-12-18
Posts: 819

Re: Overpass "not equal" operator for values

What elements do you want to get? If you ask for e.g. highway not equal residential you probably want all highways excluding those with hw=resdidential? In this case you have to use something like highway=* and highway!=residential.

Offline

#3 2019-04-21 15:53:52

ghowen
Member
Registered: 2018-11-25
Posts: 5

Re: Overpass "not equal" operator for values

Yes, thanks, I figured that out. I was just wondering why the "key != value" includes all elements that do not match the key.

Offline

#4 2019-04-21 18:16:56

GerdP
Member
Registered: 2015-12-18
Posts: 819

Re: Overpass "not equal" operator for values

I think most programs follow this logic.
Example: When I search for "highway=* and area!=yes" I want to get highways which do not have an area tag or those where this tag is not equal to "yes". I would be very surprised to get only those highways which also have an area tag.

Offline

Board footer

Powered by FluxBB