1

Hello, with overpasss-turbo I want to query different names. Problem is: I don't know exactly which key/tag/feature the name has (I mean that I don't know if it's the name of a "natural:peak" or a "natural:glacier" or a "place:region" etc). But what I know is, that not all keys/tags/features should be searched (for example I know that it's not the name of a building, a bus stop or a highway). I figured out how to query a name e.g. as peak or glacier, as both are natural features:

nwr[name~"Dreitorspitze"][natural~"peak|glacier"];
out geom;

But how can I query a name for example in region and peak? I tried different versions of concatenating these expression together according to the expression above with "|" like e.g.:

nwr["name:de"~"Karnische Alpen"][[natural~"peak|glacier"]|[place="region"]];
out geom;

But this doesn't work (obviously). Is there a way to concatenate different keys/tags/features as expression together? Or do I really need to ask each name for each key individually like:

nwr["name:de"~"Karnische Alpen"][natural~"peak|glacier"];
out geom;
nwr["name:de"~"Karnische Alpen"][place="region"];
out geom;
nwr["name:de"~"Karnische Alpen"][boundary="administrative"];
out geom;

Thank you very much in advance for all your help :-)

Best regards

asked 19 Feb, 15:52

4Kala's gravatar image

4Kala
36115
accept rate: 0%

edited 19 Feb, 16:21


5 Answers:
2

To get the union of several queries at once, you can group the query statements inside parentheses like this:

(
 nwr["name:de"~"Karnische Alpen"][natural~"peak|glacier"];
 nwr["name:de"~"Karnische Alpen"][place=region];
 nwr["name:de"~"Karnische Alpen"][boundary=administrative];
);
out geom;

Another useful technique is to specify only the key and not the value, like this:

nwr[name~"Dreitorspitze"][natural];
out geom;

This will return anything tagged with natural whose name contains "Dreitorspitze", in particular it finds https://www.openstreetmap.org/way/718323342 which is natural=bare_rock.

You can also search just by name without any additional tags:

nwr[name~"Dreitorspitze"];
out geom;

But you might end up finding, for example, a restaurant whose name contains "Dreitorspitze" (though it doesn't appear any such restaurant is currently on the map.)

permanent link

answered 19 Feb, 16:34

jmapb's gravatar image

jmapb
2.2k72443
accept rate: 20%

edited 19 Feb, 16:57

1

To apply 2 sets of conditions, use a named set for the output of the first set of features:

http://overpass-turbo.eu/s/QSl

[bbox:{{bbox}}];
(
  nwr[highway];
  nwr[waterway];
 ) -> .byfeature;

 (
   nwr.byfeature[name="West Elizabeth Street"];
  nwr.byfeature[name="Pleasant Valley and Lake Canal"];
  );
out geom;

You probably want to go in the other direction, querying by name and then filtering on feature, but that should work fine.

permanent link

answered 19 Feb, 21:45

maxerickson's gravatar image

maxerickson
11.4k1075161
accept rate: 30%

1

Please consult the documentation

If you want to search for a single value then use the equal sign:

node[name="Karnische Alpen"];
out;

If you want to search for lists of values then you can use a list as regular expression:

node[name~"^(Karnische Alpen|Dreitorspitze)$"];
out;

Other variants exist, depending on the exact aim. If you want to combine multiple criteria per or then use parentheses, as maxerickson has just explained.

Finally, you can use as extra criteria also free-form logic

node[name~"^(Karnische Alpen|Dreitorspitze)$"]
    (if:t["natural"]=="glacier" || t["natural"]=="peak" || t["place"]=="region");
out;

Please note that there is currently no node with name Karnische Alpen or Dreitorspitze in the database. Thus all the queries have empty results anyway.

permanent link

answered 20 Feb, 04:35

Roland%20Olbricht's gravatar image

Roland Olbricht
6.4k35986
accept rate: 35%

edited 20 Feb, 04:39

0

Thanks jmapb for your quick answer. This will save me several lines of code :-)

so, if I understand you right, its not possible to search for something like:

name = "Karnische Alpen" AND [(natural = peak) OR (natural = glacier) OR (place = region)]

The possibility to search a key without value is also very interesting, thanks very much. I just tried, if these could be concatenated, but also failed with different version of a code like this (there is no error message, but the map is empty):

nwr["name:de"~"Karnische Alpen"]["natural|place|boundary"];
out geom;

As I need to query several hunderts of names I try to find a query with as less code as possible. So would there be a way to query each name just one time within several keys/tags/features (as a matter of fact I think - as jmapb suggested - the key without the value would be enough)? So something like this:

name = "a name" AND ("natural" OR "place" OR "boundary")

Thanks very much again :-)

Edit: just saw our edit now: the problem with a query without additional tags is, that there would be too much results. And because I know for sure, that it's not the name for e.g. a restaurant, I would like to limit the query to the possible features.

permanent link

answered 19 Feb, 17:00

4Kala's gravatar image

4Kala
36115
accept rate: 0%

edited 19 Feb, 17:04

0

Thank you very much for your answers maxerickson and Roland Olbricht :-)

With the help of you all I found the solution I need:

  (
    nwr["name:de"~"Karnische Alpen"](if:t["natural"]=="glacier" || t["natural"]=="peak" || t["place"]=="region"); 
  nwr[name~"Alpspitze"](if:t["natural"]=="glacier" || t["natural"]=="peak" || t["place"]=="region");
    );
out geom;

Thats what I was looking for, because I can generate this query automatically for all needed names and can query for specific keys/tags/features.

Thank you all three very much again for your help :-)

permanent link

answered 20 Feb, 10:34

4Kala's gravatar image

4Kala
36115
accept rate: 0%

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:

×377
×186
×126
×20

question asked: 19 Feb, 15:52

question was seen: 316 times

last updated: 20 Feb, 10:34

powered by OSQA