Creating boundary files


I want to create boundary files for Kabul map downloaded from in .osm format for Garmin Mobile XT.

I have downloaded Mkgmap(latest version), osmconvert and osmfilter and also map of Kabul city, and because map of Kabul city is only 10MB there for I don’t divide and split it to small regions.

Now when I want to create boundary files and type following commands in cmd I get errors,

when I type osmconvert kabul.osm --out-o5m >kabul.o5m

I get errors,

osmconvert Warning: wrong sequence at way 28614055
osmconvert Warning: next object is way 28612513
osmconvert Warning: wrong sequence at way 69825386
osmconvert Warning: next object is way 23841288
osmconvert Warning: wrong sequence at way 42472052
osmconvert Warning: next object is way 4398580

But the kabul.o5m file is created with 705KB size.

when I type osmfilter kabul.o5m --keep-nodes= --keep-ways-relations=“boundary=administrative =postal_code postal_code=” >kabul-boundaries.osm

I get errors,

osmfilter Warning: wrong sequence at way 28612513
osmfilter Warning: wrong sequence at way 23841288
osmfilter Warning: wrong sequence at way 4398580

But kabul-boundaries.osm is created with 13KB size.

When I type java -jar mkgmap.jar --createboundsfile=kabul-boundaries.osm

I get error,

SEVERE (BoundarySaver): Calculate bbox to (46079.99997854233,46079.99997854233)
to (-46080.0,-46080.0)
Exception in thread “main” java.lang.NullPointerException

and no bounds directory is created.

Therefor when I change the map from .osm to .img and use it Garmin Mobile XT I can’t search for addresses.

What is your recommendations what should I do to create boundary files for Kabul map and use it Garmin Mobile XT


how did you download the osm data for Kabul? When you use JOSM for it, some relations may not be completely downloaded. Make sure to download all relations manually completely.


Thanks for your reply.

I have downloaded the map for Kabul from and selecting Export and XML option. I wanted to download Afghanistan map but it wasn’t possible to download larg area then I downloaded only kabul.

And I am somehow new to creating maps, can you add some information on downloading all the relations?

Thank you.

Ok, I did it the same way now, and opened the osm-file with our editor JOSM. If you dont have it already open, press alt+shift+R to open the relation editor.
There you see the entry border[2] “Afghanistan” (incomplete). Right-click on that entry and select download incomplete elements.

Next step is downloading the province borders. Press the download icon (the third one from the left), and look for the point, where the provinces of Kabul, Parwan and Wardak join together, just a bit west from the city. Select a small area around that point, and you get the relations of the three provinces. Repeat the step of border[2] above for the three provinces.

I just found that the border relation for Kabul province is not a closed ring. You have to fix and upload that to get adress search working.

Save the result and try again osmfilter and mkgmap.


Thank you sir, I will try that and will reply with the status.

Ok, I have downloaded all the relations and got a 12.1 MB Kabul. And also has successfully created boundary files.
But when I type:

*java -jar mkgmap.jar --route --remove-short-arcs --add-pois-to-areas --index --gmapsupp .osm

I get this error:

Exception in thread “main” java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(Unknown Source)
at java.util.ArrayList.get(Unknown Source)

** at

And also no gmapsupp.img file.

What to do next?

And after fixing these will I get address search working or as you said I should first fix the border relation issue for Kabul?


Have you tried without --index? just to see if the rest of mkgmap works fine.

Ofcourse you have to close the border relations first. Its not just Kabul province, but also a few other east of the City. Borders that are not closed are useless for the adress index.

Another trial: If boundaries dont work, you can use other options for adress index:
or both:


I have tried that without --index but what I get is only 16 KB gmapsupp.img file.
After that I have download a new map of Kabul from using Export and XML option and for that every thing (without --index) worked fine.

Seems that problem is only with the file I have edited with JOSM.

Ok, I have fixed that problem. I have used the Splitter and splitted the map and tried creating gmapsupp.img file and worked fine.

Thanks for your help.

I would like to know one thing else.
I have a Topo map of Afghanistan for Garmin and is not routable, is there any way to make it routable?

If you own the contour data and also have OSM road data you can compile a routable topo with Mkgmap. If the contour map is compiled, and you don’t have access to the data your best option would be to download whatever Lambertus provides for Afghanistan and use that for routing. This works best if the contour map is transparent and doesn’t show roads. Otherwise, if road data is not from OSM there could be some graphical conflicts.

The topo map is a Mapsource unlocked folder downloaded from:

don’t know if it is able to compile it with OSM road map. If it is, can you say how I can do it.

Also please add some detail on how to create border relations.

I have closed the ring of Kabul by drawing nodes, but didn’t find what to select under “Presets”. Like other 3 members for Kabul has Board_type, Admin_level, boundary and id.
How can I add these to the border I create/add?

Best regards,

It’s not possible to use compiled IMG files to create maps.

Suggest you try here to generate contours.

Don’t know anything about relations.

Srtm2Osm is outdated, you should look instead at


Good to know, thanks.