Context: I’m trying to build maps for my Garmin bike computer with mkgmap
, and I have compiled instructions from different sources into a script.
The step that is relevant to this thread is where I combine the elevation data created by pyhgtmap
and the OSM dump downloaded from Geofabrik.
The command that I used for pyhgtmap
:
pyhgtmap --polygon=/data/poly/country.poly --step=${HGT_STEPS:=20} --hgtdir=/data/pyhgtmap/hgt/ --earthexplorer-user="${EARTHEXPLORER_USER}" --earthexplorer-password="${EARTHEXPLORER_PASS}" --pbf --source=srtm3,view3,sonn3,alos1,srtm1,view1,sonn1 --alos-user="${ALOS_USER}" --alos-password="${ALOS_PASS}"
This outputs .osm.pbf
files named lon*lat*.osm.pbf
in /data/pyhgtmap/output
. The next step is to merge these files with the OSM dump, and then the merged data goes to mkgmap
’s splitter
.
The commands that I have used for merging the data:
osmium merge lon*lat*.osm.pbf -o /data/pyhgtmap/output/country.merged.osm.pbf
osmconvert /data/pyhgtmap/output/country.merged.osm.pbf -o=/data/pyhgtmap/output/country.merged.o5m
osmconvert --drop-version /data/pyhgtmap/output/country.merged.o5m /data/osm-data/country.osm.pbf -o=/data/osmconvert-output/country.osm.pbf
However, since osmconvert
is in maintenance mode, I wanted to only use osmium
. I found that this following block also does the job, but without osmconvert
:
osmium merge lon*lat*.osm.pbf -f pbf | osmium cat -F pbf - /data/osm-data/country.osm.pbf -o /data/osmium-output/country.merged.osm.pbf
osmium sort /data/osmium-output/country.merged.osm.pbf -o /data/osmium-output/country.sorted.osm.pbf --strategy multipass
Output files of both of this works with splitter
.
The problem is that the osmium sort
command uses a huge amount of memory (as documented in the manual), at around 29 GB for Austria, whereas with osmconvert
only uses 9 GB. But without the sorting step for the newer commands, splitter
complains about the data not being sorted.
The fact that osmconvert
can do the same job with so much less memory usage makes me think that the osmium sort
command might be overkill, and the data is partly already sorted, but the merging process has some kinks that I do not understand and causes splitter
to complain. But that’s just my uneducated guess.
Does anybody have any clue, how I could efficiently merge the HGT data and OSM dump with only osmium
, without having to sort the data?