Pergunta

I'm trying to find a way to query Open Street Maps for a list of ATMs for a particular city, any ideas how to achieve this?

I know we can use mapquest to query for this information, but it needs a box and it gives me less informaton than Open Street Maps.

Thanks.

Foi útil?

Solução

I guess you meant MapQuest's Nominatim instance. Just for the record: Nominatim is actually created by the OpenStreetMap community. MapQuest just runs it, too.

Querying for specific objects is best done by using the Overpass API. This API also has a nice frontend, overpass turbo. It makes creating queries and running them really easy and also includes a nice visualization of the result.

This query will retrieve all ATMs (which are tagged as amenity=atm) in Berlin:

<osm-script output="json" timeout="25">
  <!-- fetch area “berlin” to search in -->
  <id-query {{nominatimArea:berlin}} into="area"/>
  <!-- gather results -->
  <union>
    <!-- query part for: “atm” -->
    <query type="node">
      <has-kv k="amenity" v="atm"/>
      <area-query from="area"/>
    </query>
  </union>
  <!-- print results -->
  <print mode="body"/>
  <recurse type="down"/>
  <print mode="skeleton" order="quadtile"/>
</osm-script>

You can view the result on overpass turbo. This query has been automatically generated by overpass turbo, I just had to type "atm in Berlin" into it's wizard.

Note that this is a special overpass turbo query which cannot be run directly via the Overpass API. overpass turbo adds some extra keywords like {{nominatimArea:berlin}} which will be automatically replaced by the bounding box of Berlin returned by Nominatim. But if you already know the bbox or want to retrieve it on your own using Nominatim, then you can specify it directly:

<osm-script output="json" timeout="25">
  <!-- gather results -->
  <union>
    <!-- query part for: “atm” -->
    <query type="node">
      <has-kv k="amenity" v="atm"/>
      <bbox-query e="13.92242431640625" n="52.67221863915279" s="52.32778621884898" w="12.992706298828125"/>
    </query>
  </union>
  <!-- print results -->
  <print mode="body"/>
  <recurse type="down"/>
  <print mode="skeleton" order="quadtile"/>
</osm-script>

Both the Overpass API and overpass turbo support various output formats for the result, including XML and JSON.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top