Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
    
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 '12 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 '12 at 10:12
    
how did you import the osm file into postgis? –  Stev_k Mar 6 '12 at 11:44
    
@Stev_k using this: osm2pgsql -U user RU-SPE.osm –  k102 Mar 6 '12 at 12:46
add comment

2 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
thanks! this worked! but i found nominatim simplier: readme is here. –  k102 Mar 7 '12 at 9:51
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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