Helo, I Have this query

area["name"="London"];
node(area)["amenity"="bar"]->.all;
( .all; - ._;);
(._;);
out;

but for less queries to overpass server i want to join more categories to one query, I think this should be like this

node(area)["amenity"="bar" || "amenity"="restaurant"]->.all;

but i have error there.

can you please show me true syntax for getting both categories?

asked 25 Jan, 14:12

davittorosyan's gravatar image

davittorosyan
36448
accept rate: 0%

edited 25 Jan, 21:24

aseerel4c26's gravatar image

aseerel4c26 ♦
31.1k15232531


The correct syntax is

node["amenity"~"hotel|restaurant"]({{bbox}});

This is an example query

more info on the syntax can be found in the Overpass documentation on One or the other name.

permanent link

answered 25 Jan, 17:01

escada's gravatar image

escada
15.5k14130247
accept rate: 20%

You should write this:

["amenity"~"bar|restaurant"]

instead of:

["amenity"="bar" || "amenity"="restaurant"]

If you want to add more, like fast_food, pub, cafe, etc, you can do it easily:

["amenity"~"bar|restaurant|fast_food|pub|cafe"]

You have infinite other possibilities using regular expressions in overpass...

permanent link

answered 25 Jan, 17:01

edvac's gravatar image

edvac
5351416
accept rate: 14%

edited 25 Jan, 17:04

Thank you for anwser, this is works well, but in case if i should get one form amenity and another from shop?

["amenity"="bar" || "shop"="supermarket"] ...

?

(26 Jan, 07:18) davittorosyan

In that case, you better separate the queries and then union them:

area["name"="London"];

node(area)["amenity"~"bar|restaurant"]->.amenities;

node(area)["shop"~"supermarket|clothes"]->.shops;

(

.amenities;

.shops;

)->.all;

( .all; - ._;);

(._;);

out;

(26 Jan, 10:55) edvac
1

I would also change "London" by "Greater London" to avoid getting some nodes in North America, that you probably don't want: http://overpass-turbo.eu/s/voH

Or you could use the relation code instead: http://overpass-turbo.eu/s/voG

(26 Jan, 11:01) edvac
1

@edvac thanks a lot for your quick and good answer, this is great solution for me, thanks again. I have one another question but don't want add to this topic. If you can, please see this question also https://help.openstreetmap.org/questions/61819/how-get-all-ways-without-nd-tags

(26 Jan, 14:30) davittorosyan
1

You are welcome ;)

I gave you an answer to that new query. Hope it is what you want...

(26 Jan, 15:09) edvac

An alternative to the regex solution given in the other answers is to use the union operator, which is specified by grouping queries inside of parentheses:

area["name"="London"];
(
node(area)["amenity"="bar"];
node(area)["amenity"="restaurant"];
);
out;

This will likely be clearer if the query involves several different keys.

The output of the union can also be saved in a named set:

(
node(area)["amenity"="bar"];
node(area)["amenity"="restaurant"];
)->.all;
permanent link

answered 25 Jan, 19:35

maxerickson's gravatar image

maxerickson
9.5k868135
accept rate: 31%

Thank you for answer,

but when i trying to get bars and restaurants with this query

area["name"="London"];

( node(area)["amenity"="bar"]; node(area)["amenity"="restaurant"]; )->.all;

( .all; - .; ); (.;>;);

out;

i see in results ONLY bars....

where is my mistake?

(26 Jan, 07:16) davittorosyan

You need to name the area and then reference the name, see https://help.openstreetmap.org/answer_link/48795/

(08 Nov, 12:56) reubot
Your answer
toggle preview

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:

×314
×101
×42
×4

question asked: 25 Jan, 14:12

question was seen: 884 times

last updated: 08 Nov, 12:56

powered by OSQA