I want to import OSM data into a PostGIS database running under windows. After a web search I learned that I should use osmosis. But most of the explanations are for Linux. But I have to use windows. Is there a detailed description how to do that with Windows?


2 Answers 2


Osmosis is the swiss-knife for OSM data and therefore a great piece of software to handle OSM data. I'd recommend to follow the steps below to succesfully import OSM data into a PostGIS database in a windows environment:

  • First of all you need to download and install PostgreSQL with a PostGIS extension and download the latest stable version of osmosis.
  • Then you need to create the hstore extension using pgAdmin to store osm-tags in PostGIS: CREATE EXTENSION hstore;
  • Create a database-schema for OSM data: Copy the code from YourPathToOsmosis\script\pgsnapshot_schema_0.6.sql into pgAdmin and execute it. Do the same with YourPathToOsmosis\script\pgsnapshot_schema_0.6_linestring.sql to enable linestrings (there are other database schemas which might suite your needs. I prefer pgsnapshot because every single tag is imported. If you primarily want to render OSM data you'd better use the osm2pgsql schema).
  • For better performance add indices: Again, execute CREATE INDEX idx_nodes_tags ON nodes USING GIN(tags); and CREATE INDEX idx_ways_tags ON ways USING GIN(tags); and CREATE INDEX idx_relations_tags ON relations USING GIN(tags); within pgAdmin.
  • Now your database is ready to be filled with OSM data. Download your required OSM extract (e.g. from the Geofabrik download server) and use osmosis within the commande line to import a *.pbf-file: "YourPathToOsmosis\bin\osmosis" --read-pbf file="C:\YourPathToOSMFile\osm_file.osm.pbf" --write-pgsql host="localhost" database="yourDBname" user="postgres" password="yourPW"

Apart from osmosis, you can use osm2pgsql to populate a Postgis database.

For links to Windows builds, see https://github.com/openstreetmap/osm2pgsql/issues/17 and https://github.com/openstreetmap/osm2pgsql/issues/472

The advantage of osm2pgsql is that you will get GIS-ready tables with the same content as used by the rendering toolchain.

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.