0

I wanted to upload the OSM file from my local machine to server using osm2pgsql, but the data is not imported.

I have just created the database s1(no table), do I need to create the table also, if yes how?

My osm2pgsql query

osm2pgsql -c -d osm -U s1 --password xx -k -H yy  /home/g/Downloads/niedersachsen-latest.osm.pbf pbf -r -S /home/g/default.style -s

I am getting an error

Osm2pgsql failed due to ERROR: Unknown file format '-S'.
  • 1
    Please Edit the question to specify the error behavior ("not able to do it" is not useful) – Vince May 1 at 10:50
  • I have updated the question – GAUTAM KISHORE SHAHI May 1 at 11:26
  • does default.style exist? – Fran Raga May 1 at 11:38
  • I took a hint from a website and default. style I took it from GitHub, please suggest any other alternative, I need to import .osm.pbf – GAUTAM KISHORE SHAHI May 1 at 11:44
  • if that's the exact command then your syntax is wrong (e.g. it has to be -r pbf)! write that command more carefully. and check for unnecessary spaces. – ThingumaBob May 1 at 12:18
1

You can get the description of each command line parameter here or by running the command osm2pgsql -h -v

The parameter -r has the following description:

-r|--input-reader    Input format.
                        auto      - Detect file format. (default)
                        o5m       - Parse as o5m format.
                        xml       - Parse as OSM XML.
                        pbf       - OSM binary format.

In your command the value pbf is written before the -r, so it fails. You can put the parameter/value in the proper order or remove both of them, relying on the auto-detect default option.

osm2pgsql -c -d osm -U s1 --password xx -k -H yy  /home/g/Downloads/niedersachsen-latest.osm.pbf -r pbf  -S /home/g/default.style -s
  • Hello, thank you, that error is solved but getting another error Osm2pgsql failed due to ERROR: Open failed for 'password': No such file or directory – GAUTAM KISHORE SHAHI May 1 at 17:28
  • don't write the password (xx) in the command line, it will be prompted. – JGH May 1 at 18:04
  • it worked, thanks :) – GAUTAM KISHORE SHAHI May 1 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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