overpass query using suburbs

Hi everyone,

I am trying to write a query that returns me the total number of hotels for each suburb in a city. With the example below i get the total number of hotels for Hamburg. Can someone assist me with the suburbs part? I am using http://overpass-turbo.eu/





out count;

I am not sure, but maybe you have to do a query for each suburb.

Where should overpass-turbo know from all the suburbs of Hamburg? (Maybe it is possible to get the suburbs automatically, but I am not aware of that)

What about the hotels that are not mapped as node, but as a closed way / building shape? or maybe even as relation? You don’t count them so far.

That’s pretty straight forward to do:

  make result name = a.set(t["name"]),
              nodes = count(nodes),
              ways = count(ways),
              rel = count(relations);


  <result id="1">
    <tag k="name" v="Hamburg-Mitte"/>
    <tag k="nodes" v="90"/>
    <tag k="ways" v="59"/>
    <tag k="rel" v="2"/>
  <result id="2">
    <tag k="name" v="Bergedorf"/>
    <tag k="nodes" v="5"/>
    <tag k="ways" v="9"/>
    <tag k="rel" v="1"/>
  <result id="3">
    <tag k="name" v="Harburg"/>
    <tag k="nodes" v="12"/>
    <tag k="ways" v="10"/>
    <tag k="rel" v="0"/>
  <result id="4">
    <tag k="name" v="Altona"/>
    <tag k="nodes" v="21"/>
    <tag k="ways" v="13"/>
    <tag k="rel" v="1"/>
  <result id="5">
    <tag k="name" v="Eimsbüttel"/>
    <tag k="nodes" v="16"/>
    <tag k="ways" v="19"/>
    <tag k="rel" v="0"/>
  <result id="6">
    <tag k="name" v="Hamburg-Nord"/>
    <tag k="nodes" v="19"/>
    <tag k="ways" v="14"/>
    <tag k="rel" v="0"/>
  <result id="7">
    <tag k="name" v="Wandsbek"/>
    <tag k="nodes" v="19"/>
    <tag k="ways" v="12"/>
    <tag k="rel" v="0"/>

Nice. :smiley: I would press the “Thanks” button if the forum had one…

The code seems to work for Hamburg, but when I replace it with Frankfurt or Düsseldorf i get no results. Could you tell me why? Thanks!

That’s because Düsseldorf and Frankfurt have different admin levels in the OSM data, hence the query won’t find anything if you just replace the name of the city.

Check out: https://wambachers-osm.website/boundaries/ for details.

Thank you for your reply.
I tried with the different admin levels and it seems to work.

However, now i am trying to get the total number of pharmacies for each German city. How can get this done in one query if they cities have different admin levels? A query to list the city in Germany in overpass-turbo only returns a small number of cities. :expressionless: