NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

My question is similar to this one, but the only answer offered over there does not satisfy my requirement.

I need a to create a database containing the required data to auto-complete a postal address filled in by a user in a mobile application.
The database must be embed in the application, to allow for offline use and always snappy auto-completion.

In this context, my technical goal is to create a SQLite database with the cities, zip code and streets. I do not need the coordinates of the points. I have no problem converting from a classic SQL flavor database to SQLite. I'm however having trouble going from osm format to SQL.
If an other format usable in a mobile application is more appropriate, I'm of course ok with it too.

I have the feeling that I'm not dealing with the problem with the right strategy and adequate tools.
What steps and tools do you suggest?

Here is what I tried:
Using an extract from OpenStreetMap Extracts, I have successfully created a SQLite database with osm2sqlite.
I'm a bit confused about the format of the rows.
And there is a lot of information I don't care about. While I could remove it, it feels backward to import it from osm to SQL to then remove it. Would be much more efficient to not import it in the first place.

Updated to describe an other try:
Using osm2pgsql, I'm loading the file into a Postgres database.

osm2pgsql -c -G -d osm -S /usr/local/share/osm2pgsql/ france.osm.pbf

Seems nice, but I can't find the zip code. Is it not available for France in original osm file, or is it the import that skipped it?

asked 04 Dec '12, 14:52

Guillaume's gravatar image

accept rate: 0%

edited 09 Aug '16, 11:23

aseerel4c26's gravatar image

aseerel4c26 ♦

Please have a look at the OSM wiki and do a search there for the tools called osmfilter and osmconvert.

If you have your rae OSM source data, do a filtering for any objects to keep addr:* tags

Then process the result file with osmconvert where you can produce CSV data sets easily.

Then import that CSV data in any database you like.

permanent link

answered 04 Dec '12, 17:07

stephan75's gravatar image

accept rate: 6%

@stephan75 If I want to import everything in the database, do I need to run the osmfilter command (your line "do a filtering for any objects to keep addr:* tags" sounds like you need to explicitly hint you want to keep a specific tag). I will try osmconvert to write a csv. I have also updated my question, to document my latest try with osm2pgsql

(04 Dec '12, 21:40) Guillaume

hi Guillaume, Well, I am not so familiar with OSM import to an SQL database ... but if you want to know whether you NEED to do some filtering before importing: try it on your own!

Take a small raw OSM file from an area, maybe your hometown or similar, and try all features of osmfilter to find out how it works and if you can benefit from it before importing. There are enough examples about filtering on the OSM wiki page of osmfilter.

Tell us when you get stuck somewhere in detail, with adequate examples.

(05 Dec '12, 17:44) stephan75

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 04 Dec '12, 14:52

question was seen: 6,213 times

last updated: 09 Aug '16, 11:23

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum