Convert Shape file (.shp) to .map file

2,377 views
Skip to first unread message

Alejandro Mitaritonna

unread,
Apr 12, 2013, 4:22:07 PM4/12/13
to mapsfo...@googlegroups.com
Hi guys, I would like to know how I can export shape file (.shp) to .map file. I tried with Merkaator 0.17.2 version, Osmosis 0.42-6 and I had to many problems...
Anybody can help me with this issue?
Thanks!!!
Alejandro

Ludwig

unread,
Apr 12, 2013, 8:12:55 PM4/12/13
to mapsfo...@googlegroups.com
I do not think there is a way of directly converting a shape flle to a mapsforge map file, but there are some utilities that allow you to convert a shapefile to OSM. That data you can then use as input to the map file writer. Note that you will need to provide some specialist tag-mapping.xml to map the shapefile data otherwise the data will not be included in the map file. Likewise to display it you will need to include the values in the rendertheme.

Ludwig


Alejandro

--
You received this message because you are subscribed to the Google Groups "mapsforge-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapsforge-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Radek

unread,
Apr 16, 2013, 3:21:23 PM4/16/13
to mapsfo...@googlegroups.com
Hi Alejandro,

As Ludwig mentions there is no direct way to convert shape file to mapsforge file, but it can be done in few simple steps, I've managed to do this with both Merkaartor and JOSM.

If you use Merkaartor:

- Import .shp file into Merkaartor and save it as .osm file. Edit .osm file with text editor, go to end of the file and remove bounding box tag that Merkaartor adds (it will cause osmosis to fail at next step)

- Run osmosis with mapwriter plugin:

  osmosis --rx file="path_to_osm_converted_from_shp" --sort --mw file="path_to_generated_map_file" bbox=xxx,xxx,xxx,xx map-start-zoom=16 tag-conf-file=path_to_your_custom_tag-mapping.xml

At this point you should remember to specify correct bounding box. Also take notice of last tag-conf-file parameter.

The tricky part is to understand how mapwriter works. That was the part that I got stuck (thanks guys for feedback!). Take a look at:


In short - this is the file that (as far as I know) defines what tags from .osm file will be included in its binary .map representation .You can download this file, edit it and place your own tags. If you do that don't forget to define custom render theme for the map file that will tell mapsforge library how to display/draw objects from your added tags. You can read more about rendertheme at https://code.google.com/p/mapsforge/wiki/RenderThemeAPI

If you use JOSM:

- Import .shp file into JOSM and save it as .osm file to the disk. Bad news is that JOSM is not fully compatible with openstreetmaps API v0.6, so when trying to generate .map file osmosis will throw errors. My solution for this is to manually parse .osm file and add required missing tags (version, and timestamp). For this you can use SED – with this tool even big .osm files won’t be a problem.

- Run osmosis with mapwriter plugin:

  osmosis --rx file="path_to_osm_converted_from_shp" --sort --mw file="path_to_generated_map_file" bbox=xxx,xxx,xxx,xx map-start-zoom=16 tag-conf-file=path_to_your_custom_tag-mapping.xml

As above, don’t forget about current bbox parameter, tag-mapping and custom render theme. 

That should generally be it, hope this helps!

Cheers

Alejandro Mitaritonna

unread,
Apr 16, 2013, 3:31:47 PM4/16/13
to mapsfo...@googlegroups.com
Hi Radek and Ludwig, thanks for the comments.
I will try the steps mentioned by Radek.
Thank you very much.
Alejandro

Alejandro Mitaritonna

unread,
Apr 17, 2013, 6:04:33 PM4/17/13
to mapsfo...@googlegroups.com
Radek, I have a question.
when I run osmosis command, about the bbox tag, can I use the same bbox tag value that I removed on .osm file?
BR
Alejandro


El martes, 16 de abril de 2013 16:21:23 UTC-3, Radek escribió:

Radek

unread,
Apr 18, 2013, 8:41:06 AM4/18/13
to mapsfo...@googlegroups.com
Hi,

As far as I remember - yes - bound box tag that you removed should have correct values. But if you want to be 100% sure do a double check. If you define wrong bbox, created .map file can be blank (no map, blank white screen).

Correct order of bbox cordinates passed to osmosis is: minLat, minLon, maxLat, maxLon:

bbox=minLat, minLon, maxLat, maxLon

Cheers

Malice

unread,
Oct 19, 2013, 3:12:32 AM10/19/13
to mapsfo...@googlegroups.com
Instead of removing the bbox tag in  merkaator output , cut and paste the bbox tag to the third line of the osm file . Then you dont have to give the bbox arguement for osmosis
Regards
malice
Reply all
Reply to author
Forward
0 new messages