Georg Stein
Georg Stein

Reputation: 69

Extract addresses zip street city form openstreetmap pbf files

to build up a database of German cities where ic can query cities around a cup with a defined distance, i want wo export from pbf files the address data into a mysql database. I already found a good source where i can get the pbf files, but could not find a tool to export the data i want/need. perhaps somebody has had already the same problem and can help me out wit a link here.

i only need the zip, city, street and lat/lon, no map data or vector data

Georg

Upvotes: 0

Views: 955

Answers (1)

Alex
Alex

Reputation: 35118

You can use imposm to import data to a PostGIS database. Maybe it is an option to use PostgreSQL instead of MySQL, because PostgreSQL is more common in the OpenStreetMap world and you might find more tools for this.

You can customize the imposm schema to leave our the geo data you do not need.

Another way would be to use osmosis:

https://gis.stackexchange.com/questions/185793/is-there-a-way-to-retrieve-all-cities-in-the-world-from-openstreetmap

There is a --write-mysql switch:

https://github.com/openstreetmap/osmosis/blob/master/doc/detailed-usage.adoc#write-mysql-wm

So something like this should work:

./osmosis --read-pbf germany-latest.osm.pbf \
     --tf accept-nodes place=city,town,village \
     --tf reject-relations --tf reject-ways --lp \
     --write-mysql database=test user=*** password=***

Upvotes: 0

Related Questions