This is a static archive of our old OSM Help Site. Please post any new questions and answers at community.openstreetmap.org.

Search for restaurants around a distance

0

Hi,

I need the following: I'm searching for restaurants around "95448 Bayreuth" (Germany) 1000 meters.

This is what I got so far, it works nearly, but it shows also restaurants outside the 1000 meters radius:

[out:json][timeout:25];
// fetch area "Bonn" to search in
{{geocodeArea:95448 Bayreuth}}->.searchArea;
// gather results
(
  // query part for: "restaurant"
  node(around:1000)["amenity"="restaurant"](area.searchArea);
  way["amenity"="restaurant"](area.searchArea);
  relation["amenity"="restaurant"](area.searchArea);
);
// print results
out body;
>;
out skel qt;

May you help me with that, please?

asked 10 Jul '21, 16:28

alpham8's gravatar image

alpham8
26225
accept rate: 0%

edited 10 Jul '21, 16:37

Please clarify what you mean by 95448 Bayreuth as that is a boundary. {{geocodeArea:95448 Bayreuth}}; rel(pivot); out geom;

(10 Jul '21, 19:59) DaveF

2 Answers:

1

There are a number of issues with your search:

  1. You are searching for all restaurants mapped as a node which are in the entire Gemeinde of Bayreuth + those 1000 m outside that boundary. You need to find the node representing the centre of Bayreuth not the area.
  2. Additionally you are finding any Restaurants mapped as areas within (but not outside) Bayreuth (the around constraint is not applied to ways & areas.

This appears to be closer to what you want:

[out:json][timeout:25];
// gather results
(
  // query part for: “name=Bayreuth”
  node["name"="Bayreuth"][place]->.a;
  nwr(around.a:1000)[amenity=restaurant];
);
// print results
out body;
>;
out skel qt;

The place node for Bayreuth is places in a result set & that set is searched for restaurants within 1000 m. If there is more than one place with the name other approaches may be needed.

answered 10 Jul '21, 19:34

SK53's gravatar image

SK53 ♦
28.1k48268433
accept rate: 22%

1

If you want all restaurants within the boundary of Bayreuth:

{{geocodeArea:95448 Bayreuth}}->.Bayreuth;
rel(pivot.Bayreuth);
out geom;
nwr[amenity=restaurant](area.Bayreuth); 
out center;

If you want all restaurants around the node of the town.

node[place][name=Bayreuth];
nwr(around:1000)[amenity=restaurant];
out center;

answered 10 Jul '21, 20:15

DaveF's gravatar image

DaveF
3.3k8498133
accept rate: 16%