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

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 '18, 14:12

davittorosyan's gravatar image

davittorosyan
51448
accept rate: 0%

edited 25 Jan '18, 21:24

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554


-1

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 '18, 19:35

maxerickson's gravatar image

maxerickson
12.7k1083176
accept rate: 32%

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 '18, 07:16) davittorosyan

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

(08 Nov '18, 12:56) reubot

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 '18, 17:01

escada's gravatar image

escada
19.0k16166302
accept rate: 21%

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 '18, 17:01

edvac's gravatar image

edvac
6652619
accept rate: 15%

edited 25 Jan '18, 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 '18, 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 '18, 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 '18, 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 '18, 14:30) davittorosyan
1

You are welcome ;)

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

(26 Jan '18, 15:09) edvac

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
×65
×4

question asked: 25 Jan '18, 14:12

question was seen: 6,978 times

last updated: 08 Nov '18, 12:56

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