Splitting img files into multiple smaller files

I’ve got a Garmin Edge 530 and it seems that the max file size is ~4gb. I’ve prepared the europe osm.pbf from geofabrik using these two commands

java -jar .\splitter.jar .\europe-latest.osm.pbf
java -jar .\mkgmap.jar --route --add-pois-to-areas --bounds=bounds --index --gmapsupp 6324*.osm.pbf

The file output size is ~15gb which is too large. Then I tried downloading a few countries, converting the osm.pbf to .o5m format, combining the .o5m files and convert it back to .osm.pbf format. Then I did run the commands above again for the combined countries and it’s 5gb. But even this is too large because the Garmin Edge 530 is FAT32.

Is there any way to limit the max file size via mkgmap or split the .img file afterwards into files of ~2gb?

I tried running the two commands above with --mapname=63240001 and --mapname=63240002 but one of the maps had a weird issue because a part of the map did not render but the other map had no issues.

Hope any of you could help me out as I’ve started recently with creating my own maps for Garmin from OSM.

You can change the file size with --max-nodes, with 1600000 the file size will be smaller.
See https://www.mkgmap.org.uk/doc/splitter.html

If you want a map of Europe you can do two things:

  1. reduce the details so that the gmapsupp.img is below 4G or
  2. create 4 or 5 separate gmapsupp files, each containing a subset of the files generated by splitter.

I can give more details if needed.

I would like to create a few separate gmapsupp files. If you could provide details and steps how I can achieve this it would be awesome!

I read that --family-id=, --product-id= and --mapname= exists, but I don’t know how to use them correctly.

OK, if you install more than one gmapsupp (a mapset) on a device you have to make sure that each tile within those mapsets has to be unique. Also, each mapset needs a unique family-id. The splitter program has an option --polygon-desc-file which was implemented to help with this but during the last days I learned that it is quite difficult to produce the corresponding polygons.
First of all don’t use whole Europe to learn how this works, start with a single country like maybe Bulgaria.

I presume that you want
a) mapsets which don’t overlap and
b) have no gaps (no (possible very narrow) empty areas between tiles of different mapsets
c) routing between different mapsets

I presume that you have a machine with

My approach would be to devide the large file into 4 or more tiles first using the --num-tiles option of splitter. Next split each tile into a set of tiles suitabe for mkgmap. Each set gets it own mapid. Unfortunately there is no garantee that each mapset stays below 4G, so maybe use more sets for Europe.
Here is one example workflow to produce the mapsets. Note that I do this on Windows, modify the \ to / if you work with a different system. The 4G for heap are not needed for Bulgaria but should be good for Europe.

osmconvert bulgaria-latest.osm.pbf --drop-version -o=f:\osm\bulgaria.o5m
java -Xmx4G -jar d:\splitter\splitter.jar --num-tiles=4 --output=o5m --write-kml=split4.kml f:\osm\bulgaria.o5m > split4.log

java -Xmx4G -jar d:\splitter\splitter.jar --no-trim --write-kml=4711.kml --mapid=47110001 --output-dir=4711 63240001.o5m > split4711.log
java -Xmx4G -jar d:\splitter\splitter.jar --no-trim --write-kml=4712.kml --mapid=47120001 --output-dir=4712 63240002.o5m > split4712.log
java -Xmx4G -jar d:\splitter\splitter.jar --no-trim --write-kml=4714.kml --mapid=47140001 --output-dir=4714 63240004.o5m > split4714.log

Now you have 4 sets of tiles in sub directories 4711…4714. The tiles should neither overlap nor have gaps. I load the kml files into JOSM (with the opendata plugin) to verify this. I really recommend to do this before finally using mkgmap!
Next, compile one gmapsupp. I suggest to create a config file mkgmap.cfg for the options that should be identical for all tiles:

# see sample.cfg for some other recommended options

Here is the command to compile the gmapsupp for 4711:

java -Xmx4G -jar d:\mkgmap\mkgmap.jar --output-dir=map4711 --family-id=4711 --family-name=fam4711 --area-name=area4711 --description=map4711 -c mkgmap.cfg  -c 4711\template.args
move map4711\gmapsupp.img map4711\map4711.img

Install the map (map4711.img) and check if you are happy with it. Try to find places, try to route between places etc.
If not, add or modify the options in mkgmap.cfg, for example you may want to use unicode codepage 65001 instead of 1252 or further args to improve routing. Make sure to rename / remove the output directory of mkgmap (map4711) first!
Once you are happy with that single mapset, compile another next to it and install it as well (simply replace all 4711 by the other number)
Enable both mapsets and check if search works well for objects in different mapsets and that routing across mapset boundaries also works well.

Finally, it should be fine to compile and install the remaining two gmapsupp files.

If you want to repeat these steps some months later you should keep the file areas.list that was produced in the first split with --num-tiles.
Use this file to split into the four same areas again:

java -Xmx4G -jar d:\splitter\splitter.jar --split-file=areas.list --output=o5m --write-kml=split4.kml f:\osm\bulgaria.o5m > split4.log

This allows to use more meaningfulll names like West/North etc. instead of area4711 or map4712 and is also faster.

Edit: fixed typo
Edit2: Clarify the repeat with areas.list

Sadly this does not completely work. I’ve done all the steps correctly but only a single part is visible. I tried belgium for example. Only one part (1/4th) of belgium has roads, but the other part has none.

As you said I replaced 4711 in the mkgmap command to 4712, 4713 and so on. On my garmin device I see a single map that is enabled with the name map4711. But i’ve moved over all .img files that I renamed from gmapsupp to map4711.img, map4712.img and so on.

What could be the issue?

I’ve added the --mapname=63240001 flag for each command again. --mapname=63240001, --mapname=63240002, --mapname=63240003, --mapname=63240004. Now I see all three maps map4711, map4712, map4713 and map4714 in my garmin map list. But there is a visibility issue. Hope you can help me out, i’m very close! :slight_smile:

Please upload your log files to https://files.mkgmap.org.uk/ and I’ll try to find out what went wrong. I’ve no idea where you added --mapname=63240001 and it should not be done for my examples.

Maybe I wasn’t clear enough about the further commands for mkgmap? This would be the one for 4712:

java -Xmx4G -jar d:\mkgmap\mkgmap.jar --output-dir=map4712 --family-id=4712 --family-name=fam4712 --area-name=area4712 --description=map4712 -c mkgmap.cfg  -c 4712\template.args
move map4712\gmapsupp.img map4712\map4712.img

Or maybe you also have to add option --x-mapset-name=ms4712:

java -Xmx4G -jar d:\mkgmap\mkgmap.jar --output-dir=map4712 --family-id=4712 --family-name=fam4712 --area-name=area4712 --description=map4712 --x-mapset-name=ms4712 -c mkgmap.cfg  -c 4712\template.args
move map4712\gmapsupp.img map4712\map4712.img

Edit: Option --mapset-name is not documented, needs to be --x-mapset-name=ms4712 , but it is unlikely to fix something. I’ll double check my commands tomorrow.

Thanks for your response. I tried running everything again from scratch. I tried belgium and france as two separate maps and splitting both into 4 and seems like it’s working. No idea why the first time with only belgium didn’t work. I also tried just belgium after running the commands again which worked fine. Might be something on my end. On a zoompart somewhere on the middle some parts of the map are not visible / missing. But on detailed / high zoom level it’s showing everything correctly. That’s the only thing that matters for me while cycling! No more waiting for garmin to update the maps :smiley:

I’ll try whole europe this weekend and remove some details with osmfilter. Thanks! Will let you know how it went.

Great! For Europe, maybe use numbers which allow +1000 tiles in one mapset, like 4410, 4420, 4430, 4440 or so.
Regarding gaps and zoom: If you don’t use the default style check the --levels option. Don’t use a resolution below 13 or change the initial split to use --resolution=12 or lower. I don’t know if the Edge 530 comes with a basemap?

How / Where can you use osmfilter in this scenario?

The Edge 530 comes with a basemap that only contains city names and highways.

I use osmfilter to make the total mapsize of europe smaller by only extracting roads, buildings and place names for example. If I go directly from osm.pbf to img the filesize is ~15gb which is more than the total size I got on my Edge :wink:

I’m interested in the exact command(s) because I found it difficult to filter things without losing important data.
Another point: If you want to use the map for bicycle routing you may want to use a different style or one of the available maps from here: https://wiki.openstreetmap.org/wiki/OSM_Map_On_Garmin/Download#Europe

Thanks for the info, will take a look. I’ll post the commands I use this weekend when I’m busy again with the maps for my garmin! :smiley:

I had time tonight to do the europe map. I used the following command to filter out all highways / roads and place names.

osmfilter europe.o5m --keep="highway=* or place=counry or place=state or place=region or place=province or place=district or place=country or place=municipality or place=city or place=town or place=village or place=hamlet or place=isolated_dwelling or place=farm or place=allotments" --out-o5m >filtered-europe.o5m

Then I used the filtered-europe.o5m to split them into 10 and done the steps you provided. Everything works fine!

I still need to take a look at the zoom level. Haven’t tried out the --levels flag yet. Will to later.

When I bought the Garmin Edge 530 I updated to the latest europe cycling map. And on my first ride I came across a road that did not exist on the map. Now I’m not dependent on Garmin to push updates and can update the map on my own now. Thanks again for all the help you provided!

Thanks for the command. It will remove some information that is needed for routing, esp. the type=restriction relations (no-left-turn etc).
Maybe not so important for a cyclist?

Address search will also suffer but you didn’t use the --housenumbers option anyway.
I’m surprised to see that you are not interested in POI like restaurants, shops, hotels etc. Maybe you use a smartphone to find those?

Note that the default style isn’t optimized for bicycle routing, more for cars. Major roads are preferred, so bicycle routing will not work well. You probably want to add option --make-opposite-cycleways, maybe also --link-pois-to-ways so that barrier nodes are considered.

It is also possible to add contour lines and hill shading to the map. I think the latter isn’t very useful on the device, only in PC programs like Mapsource/Basecamp.

BTW: When I bought my first Oregon 300 ~ 11 years ago I was very surprised to find that it came with a map that didn’t support routing at all. That’s how I found OSM and mkgmap. Since then I support both :slight_smile:

Edit: You probably had to use a reduced --max-nodes value for splitter with the filtered input?

For my Edge 530 I don’t create routing to get to a point via my device. I always create my routes first (GPX) and load them onto my device. Might add restrictions to the filter and also buildings just in case. I forgot to filter out the buildings :smiley: But not very important for now, maybe in a month or two when I update the map again.

When I go for a long ride I mostly look at POI like restaurants first on my PC / phone in which town I want to grab lunch or something. Might as well add POI with the buildings next time I update the map.

Are there any styles available I can use while creating my maps? I know there are TYP files and normal styles. Didn’t look much into that topic yet.

And yes you are correct! I added --max-nodes=16000 to lower the amount of details there are in a single map. On some of the 10 parts that I splitted them into I got a message from mkgmap that there are too much roads / details. Needed to split them further.

–max-nodes=16000 is very small. I’d expect that a value like 500000 or maybe even 800000 should work. Avoid to create lots of very small tiles.

Will try soon with a higher value and see how it goes.

You have any idea if there is a website / list for cycling styles or map styles I can choose from?

Some of the map providers also provide links to their styles. See e.g.