1

There are different ways to define search areas using Overpass API.

For example:

Geocode area

[out:json][timeout:25];

{{geocodeArea:Bonn}};

node[tourism=hotel](area);

out body;
>;
out skel qt;

Area query returning unique result

[out:json][timeout:25];

area["de:amtlicher_gemeindeschluessel"="05314000"];

node[tourism=hotel](area);

out body;
>;
out skel qt;

Find more details here in the Overpass API documentation.

But what if I want to define a set of areas that I want to use in an iteration afterwards (e.g. a set of selected large cities)? Is there a way to create something like an "array of areas" to be used for the following tag queries?

1 Answer 1

0

To filter by multiple areas, the union statement can be used.

Here's an example that shows the number of hotels within the largest German cities based on OpenStreetMap data (with the foreach part inspired by this GIS SE answer):

[out:csv(city, hotels)];
(
  {{geocodeArea:Hamburg}};
  {{geocodeArea:Berlin}};
  {{geocodeArea:München}};
  {{geocodeArea:Köln}};
  {{geocodeArea:Frankfurt}};
  {{geocodeArea:Stuttgart}};
);
foreach->.c(
  nwr(area.c)[tourism=hotel];
  make count city = c.set(t["name"]),
             hotels = count(nodes) + count(ways) + count(relations);
  out;
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.