Error with mkgmap

Hello, when I try to make an img-file with mkgmap I get following error:

Error at line 9950949, col 5
Bad file format data.osm

I got the osm-file on the following way:

wget,31.69,-111.64,37.55 -O c:\users\bs\documents\mkgmap\data.osm

Its size is quite big: 1,5 GB

Who can help me making the img-file?

Well, first you need to split the OSM file using splitter. But it does sound like you’ve got a corrupt OSM file too.

It might be better to download big chunks like this from either cloudmade or geofabrik or any other planet dump provider.


I tried splitter this way:

java -Xmx2000m -jar splitter.jar data.osm

but I got following error message:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the java virtual machine

What can I do?


yes I looked already on the websites in order to get prefabricated img-files. But unfortunately I could not find a good map. I guess I really have to get it directly from OpenStreetMap.



You should try reducing the -Xmx command. It all depends on how much actual RAM you have in your system. I have 3GB RAM and use -Xmx1000m for most areas.

yes! Now it works better. But still not perfect. I got following error:

java -Xmx1000m -jar splitter.jar data.osm
Elapsed time: 0s Memory: Current 4MB (0MB used, 4MB free) Max 992MB
Time started: Sat Feb 20 20:34:26 CET 2010
Map is being split for resolution 13:

  • area boundaries are aligned to 0x800 map units
  • areas are multiples of 0x1000 map units wide and high
    The input osm file(s) will be re-parsed during the split (slower) because no --c
    ache parameter was specified
    Processing data.osm
    2.500.000 nodes processed…
    Error parsing xml from file org.xmlpull.v1.XmlPullParserException: end tag name
    must match start tag name from line 2 (position: TEXT seen …</no
    de>\r\neset='2144684'>\r\n … @9950949:10)
    org.xmlpull.v1.XmlPullParserException: end tag name must match start tag
    name from line 2 (position: TEXT seen …\r\neset='2144684'>\r\n
    at org.xmlpull.mxp1.MXParser.parseEndTag(
    at org.xmlpull.mxp1.MXParser.nextImpl(
    Time finished: Sat Feb 20 20:35:06 CET 2010
    Total time taken: 40s

Any ideas how to solve this?

Now the problem is a damaged OSM file. Why don’t you try using a small Geofabrik extract instead (at least until you know that everything is working properly)? Once you’ve got things working, you can download an entire continent from Geofabrik if you need to (though you’ll end up with a lot of tiles you don’t need, unless you manually create an areas.list file for splitter).


sorry but on the geofabrik website I do not find any maps from western USA (California, Arizona, Utah, Nevada). And that’s the area I need. Could you advise me where to find something for me?

Anyway I would prefer to repair the damaged OSM file. Could you advise me how to do that?



From the error message I would conclude that the osm file is incomplete. (e.g. a failed/incomplete download) So even if you repaired the XML structure of that file so that the splitter and mkgmap no longer complain you would get no or a incomplete Garmin IMG-map out of it.

On geofabriks website you can only get a complete north-America extract, thats right. But you could split the whole northamerican extract into tiles for mkgmap with splitter in one step and only use the part you are interested in. Or have a two step split by first splitting out the western US states of it in one pice (using splitter with a preconfigured areas.list file, or osmosis), then split that part into managable tiles for mkgmap. The only possible problem with this is that to split the whole of northamerica with splitter you probably need 4GB of memory (or more).

I can provide a (Linux) bash script (incl. sample areas.list files) which does such a two step split. It does currently split the parts needed for a D-A-CH (Germany, Austria, Swiss) map out of the europe extract and generates the IMG files (including a NSIS-installer to install the generated map in MapSource). It should be relatively easy to adapt that for other regions.

Micha H.

Hi Micha, sorry but I do not find anything from North America. Could you send me a link?

Hm… there used to be a north America extract at the geofabrik site. Now that I look at it again, it seems they pulled it… sorry.

The next possible source would be cloudmade. But then, I see they only have state extracts, not the whole US. This makes it difficult to generate a Garmin map that contains more than one state and allows routing over state boundaries, if you to not have this requirement (routing over state boundaries) you can try these.
If you want to route over state boundaries, unless you find another place that provides US extracts, you would need to cut the region you want out of the whole planet file yourself. But I would use osmosis for that, splitter is faster but requires much more memory (and can only split rectangular regions).

Micha H.