May 252013
Article MySQL

The “osmosis” tool can be used to import an XML OpenStreetMap dump file into a MySQL database, but the structure of the database needs to be created beforehand.

Create the database and the tables

To do it, download the zip file that contains a osm_createdb.sql script with the SQL sentences that create the OSM tables. Once uncompressed, execute the script:

The script creates a database named ‘osm’, and inside this database create the tables ‘changesets’, ‘relations’, ‘ways’, ‘nodes’, etc… that will contain the different elements that are part of the OSM data.

Import the OSM file

To do the import, download the osmosis tool (written in Java).

The following example shows the command to import into the database the file “planet.osm.bz2”:

 Posted by at 8:46 pm

 Leave a Reply