1

I use the Overpass API to get the streets and public places of Budapest. I used the following query to get it:

<union>
  <area-query ref="3600037244"/>
  <recurse type="node-relation" into="rels"/>
  <recurse type="node-way"/>
  <recurse type="way-relation"/>
</union>
<print mode="body"/>

It looks usable, but I need the city districts too. I have found that the city districts are in the addressparts here: http://nominatim.openstreetmap.org/reverse?format=xml&lat=47.4959374&lon=19.1174585&zoom=18&addressdetails=1 How can I get this data for all the places I downloaded from the original query?

Kiss László
  • 265
  • 4
  • 16

3 Answers3

2

You can' retrieve this information via the Overpass API because this API is only for downloading raw and unprocessed geodata from OpenStreetMap. But in order to determine which street and place belongs to which district geocoding is required.

You already figured out that Nominatim offers (reverse) geocoding, but only for a single address or a single coordinate at a time. You have to run a query for each street and each place individually. But this will get you into troubles because it doesn't comply with the usage policy of OSM's official Nominatim instance which runs on funded servers. There are two options: Either choose another instance, for example the Nominatim instance provided by MapQuest, or install your local Nominatim instance.

Another possibility would be to get all boundary=administrative relations in Budapest (for example via the Overpass API) and do the geocoding yourself. But note that this requires some thinking and post-procession because a single street can be part of multiple districts.

scai
  • 20,297
  • 4
  • 56
  • 72
  • Thanks for your answer! Unfortunately, I really don't know how to use Nominatim. Can't you give me some tutorial for dummies about it? I tried the boundary=administrative method too and with it I got the city districts well, but I do not know how to connect it to the streets and places. – Kiss László Nov 07 '13 at 20:38
  • The Nominatim page in the OSM wiki already contains an example. You have to run a query for every place for which you want to determine the address *unless* it already has [address tags](https://wiki.openstreetmap.org/wiki/Key:addr). For "connecting" the boundary with the streets/places you have to do spatial calculations. You have the coordinates of the boundaries and of the streets/places. Now you have to determine which street/place is contained in which boundaries. The best solution is to use a database like PostgreSQL/PostGIS which already offers those spatial functions, or Nominatim. – scai Nov 08 '13 at 07:38
0

You can use Overpass API 0.7 to get areas to which point belongs (is_in) check example for the same coordinates: http://overpass-api.de/api/interpreter?data=is_in(47.4959374,19.1174585);out; It's even more precise - as nominatim tries to find nearest building and uses it as a reference point.

0

Please check the following description on how to add city/county details to each information signpost:

https://help.openstreetmap.org/questions/35976/add-reverse-geocoding-information-to-the-overpass-resulting-set

This works with is_in but is also geared towards handling a larger number of objects by using foreach.

mmd
  • 3,423
  • 1
  • 16
  • 23