NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

Hi,

So you can go : to only include tags that have a certain string: name:foo (only places with foo anywhere in the name will show up), but I'm wondering if you can do the opposite, I want to EXCLUDE tags if they contain a certain word (I want every tag that does NOT contain the word foo in the example above).

I'm sure there must be a way, there's = and !=, so I'm sure they'll be some equivalent for contains, but it certainly isn't !: and I cannot find it in documentation.

Thanks in advance for your help, Steven.

asked 12 May '21, 22:53

AutisticRabbit's gravatar image

AutisticRabbit
46114
accept rate: 0%

Can you provide an example illustrating what you want?

(13 May '21, 00:45) maxerickson

I'm intrigued/confused by your first sentence. Do you have a working example to clarify what you mean?

(13 May '21, 02:39) DaveF

Yes sorry, so I am wanting to see all the churches of a specific denomination, but the denomination field isn't always filled in, so I will need to do some manual filtering. I thought a way to narrow down the list though would be to exclude results that mention a denomination in it's name, so for example if it was Trinity Evangelist Church, I want to exclude all names that contain the word Evangelist.

@DaveF Sorry what I was meaning by the first sentence is that I can do the opposite, I know how to ONLY find churches that have the word Evangelist in the name, but I don't know how to EXCLUDE churches that have the word Evangelist from the results.

Sorry for the confusion.

(13 May '21, 09:29) AutisticRabbit
1

Try with the operator "!~" which searches for values not matching a regular expression (https://wiki.openstreetmap.org/wiki/Overpass_API/Overpass_QL#Value_matches_regular_expression_.28.7E.2C_.21.7E.29); please notice that not having the tag is considered a non match, thus it's shown in the result. If you want to avoid that, just add the filter ["name"]; Example: node["amenity"="place_of_worship"]["name"]["name"!~"Evangelist"](area.searchArea);

(13 May '21, 13:02) MarcoR

@MarcoR Yes that worked! Thank you. If you post that as an answer, I will mark it as correct.

(13 May '21, 13:27) AutisticRabbit

I know how to ONLY find churches that have the word Evangelist in the name, but I don't know how to EXCLUDE churches that have the word Evangelist from the results.

Try with the operator "!~" which searches for values not matching a regular expression.

Please note that not having the tag is considered a non match, thus it's shown in the result. If you want to avoid that, just add the filter ["name"].

Example:

[out:json][timeout:25];

  nwr["amenity"="place_of_worship"]["name"]["name"!~"Evangelist"]({{bbox}});

out body;
>;
out skel qt;

Another way to obtain the same result is to use the difference:

[out:json][timeout:25];

(
  nwr["amenity"="place_of_worship"]["name"]({{bbox}});
-
  nwr["amenity"="place_of_worship"]["name"~"Evangelist"]({{bbox}});
  );
out body;
>;
out skel qt;

The former should run faster but I think it depends on the area you are running it in.

permanent link

answered 13 May '21, 18:47

MarcoR's gravatar image

MarcoR
6873820
accept rate: 23%

Although MarcoR's former example is the preferable solution the 'difference' example, when it's the only option, can be improved slightly by passing the first call to a variable. In this example I display all edits for the last day except my own. (You'll need to add your own username)

   (
    nwr(newer:'{{date:24Hour}}')({{bbox}})->.Data;
    -
    nwr.Data(user:Joe_B);
   );
   out meta geom({{bbox}});
permanent link

answered 14 May '21, 16:30

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×483
×228
×2

question asked: 12 May '21, 22:53

question was seen: 5,061 times

last updated: 14 May '21, 16:30

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum