convert large .pbf to .map using osmosis
Prerequisites:
– osmosis
– mapsforge-map-writer plugin
– as much free HD space as possible
Download Osmosis and mapsforge-map-writer plugin as specified in their docs (as of writing this I used osmosis-0.48.2
and mapsforge-map-writer-master-20200902.143123-360-jar-with-dependencies.jar
). Inside of /osmosis
root folder create a /plugins
folder and put mapsforge-map-writer-<version>-jar-with-dependencies.jar
inside it.
You can run Osmosis from /bin
folder – if any additional plugins are present inside the /plugins
folder, you will be able to use additional options when running commands.
By default Osmosis runs in-memory (default type=ram
), however for large map conversions, it can run out of memory and even allocating more (JAVACMD_OPTIONS=-Xmx8G
or more) is sometimes not enough (throwing OutOfMemory: Java heap space
).
Switching to type=hd
, it offloads the temporary data to your hard drive:
osmosis --rb file=your_map_file.pbf --mapfile-writer file=converted_file_name.map type=hd
Above command will store temporary files in your OS temporary folder location instead of using memory, but the process itself takes more data, so you need a larger amount of free space compared to running type=ram
Note: You can run java -XshowSettings
and check java.io.tmpdir
value to see your temporary files location. In case your drive is full, it can be changed to another drive if you need more space. To convert a ~2.5GB .pbf file I needed ~50.0GB of free space for temporary files. I did the conversion on a Windows 10 machine, but it works the same on Linux.