Search code examples
openstreetmappostgisosm2pgsqlosm.pbfosmium

Impossible to merge osm.pbf file properly


I've recently started to work on a project with SRTM datas and I've extracted pbf file using phyghtmap.

To start I'm getting hgt files, converting them to tif using the following command : gdal_fillnodata.py data.hgt data.tif

Then I'm warping them with gdalwarp -co BIGTIFF=YES -co TILED=YES -co COMPRESS=LZW -co PREDICTOR=2 -t_srs "+proj=merc +ellps=sphere +R=6378137 +a=6378137 +units=m" -r bilinear -tr 90 90 data.tif warp-90.tif

And finally creating the pbf file with phyghtmap --max-nodes-per-tile=0 -s 10 -0 --pbf warp-90.tif

The results is a list of pbf files. They are perfectly fine when I load them into PostGIS with osm2pgsql. But I want to merge them to fasten the import.

I've tried all the major solutions:

  • osmium merge *.pbf -o merged.pbf

  • convert pbf to o5m then osmconvert64 *.o5m -o=merge.o5m then convert back to pbf

  • merging two by two with osmosis --read-pbf lon4.00_5.00lat44.00_45.00_local-source.pbf --read-pbf lon5.00_6.00lat44.00_45.00_local-source.osm.pbf --merge --write-pbf osmo_merge.osm.pbf

None of them worked and the result is only a very small fraction of the data merged in the result file.

Am I doing something wrong?

Note: If I load all pbf with --append it works, but it take ages for a very small portion of the world.


Solution

  • I found the issue. I wasn't setting the --start-node-id and --start-way-id in my script so all my pbf was using the same id range. Now I'm assigning unique ID and it work like a charm :)