9

I have a few (~50) PBF files came from SRTM conversion using phyghtmap.

How to merge all of them before importing with osm2pgsql?

17

You can use osmium for merging:

osmium merge file1.osm file2.osm -o merged.osm.

Alternatively try osmosis:

osmosis --rx file1.osm --rx file2.osm --merge --wx merged.osm

Note that osmosis has a weird syntax and you need to specify the --merge commands n-1 times for merging n files.

6
  • Ok. But how to merge several files at once? I have a lot of them.
    – Magno C
    Jun 6 '17 at 11:18
  • 2
    Just specify as many files as you want: omium merge file*.osm -o merged.osm.
    – scai
    Jun 6 '17 at 11:21
  • 1
    BTW: Can I do the same with PBF files?
    – Magno C
    Jun 6 '17 at 13:22
  • 1
    Can't find merge option. : osmcode.org/osmium-tool/manual.html#command-line-completion
    – Magno C
    Jun 6 '17 at 13:25
  • 2
    For PBF files use osmosis --rb file1.osm --rb file2.osm --merge --wb merged.osm. rx is for XML files.
    – Milanka
    Jul 26 '19 at 12:24
6

On Ubuntu:

sudo apt-get install osmium-tool
osmium cat new-york.osm.pbf new-jersey.osm.pbf connecticut.osm.pbf -o ny-nj-ct.osm.pbf
1

osmconvert did trick for me on windows for two files.

osmconvert a.pbf --out-o5m | osmconvert - b.pbf -o=all.pbf

https://wiki.openstreetmap.org/wiki/Osmconvert

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.