I've got an osm file containing the city I live in. Now I've got a tool to render and display it in the browser (mapnik+postgis+tilecache+openlayers+geoext) and the task is to make an address search.

I know that I can use nominatim (and actualy I use it for now), but I'd like to create my own service.

So the question is: how can I (if I can) get all adresses and their coordinates from the osm file or it's exported to postgis version?

  • Do you just want to get addresses which have been tagged with address=* in OSM? Have you checked how many there are in your city - coverage of addresses is not that great yet in OSM.
    – Stev_k
    Mar 6, 2012 at 9:30
  • @Stev_k what i need is to get a table with two fields: address and coordinates. i don't know how to make it, so any help will be great
    – k102
    Mar 6, 2012 at 10:12
  • how did you import the osm file into postgis?
    – Stev_k
    Mar 6, 2012 at 11:44
  • @Stev_k using this: osm2pgsql -U user RU-SPE.osm
    – k102
    Mar 6, 2012 at 12:46

2 Answers 2


Have a look to see if there are any columns in your database named "addr" or similar. If there are then you may be able to query the database directly and isolate these rows.

If not, you probably need to create a database schema with address tags included from scratch. Broadly how I might go about doing it is as follows:

  1. Run the raw .osm datafile through Osmosis, filtering out only those tags with an addr:* prefix. Probably using the --tag-filter. It might be easier to filter out only points, but some polygons may have the tag as well.
  2. As part of the same osmosis task, dump the resulting filtered data into a postgis database. You may need to develop a custom schema for the addresses, as they may not be imported by default
  3. Generalise the resulting data if you have line or polygon objects (e.g. get centroid) so that each address has one co-ordinate.
  4. Query the database for your geocoded addresses

Steps 1 and 2 could be replaced by creating your own osm2pgsql schema, which might be easier.

If this seems like a lot of work that's because it is. AFAIK there are relatively few osm tools to support getting addresses like this at the moment, but happy to be corrected. I would check before you start that it's going to be worth your while - i.e. people have been busy in your area tagging addresses on the map and address tags are not very sparse.

  • thanks! this worked! but i found nominatim simplier: readme is here.
    – k102
    Mar 7, 2012 at 9:51

If you just want to create your own service (and not the processing itself, which is complex as posted above), you might like to setup your own Nominatim instance: http://wiki.openstreetmap.org/wiki/Nominatim

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.