Creating OSM Offline tiles using Maperitive

MapIt offline extension is allowing to use prepared earlier basemaps when there is no Internet connection available. Please follow this guide to create .mbtiles file which you can then use as an alternative base map.

There is number of commercial application allowing you to create such a file, but in this article we will focus on the open source solution and the Maperitive software.

You can download the application from here. You need to unzip the file, and run Maperitive.exe. Maperitive may take a while to start up, just wait.

Linux or Mac OS X users can follow this guide to install the software.

The full documentation for the Maperitive is available here, however following this sample guide you will be able to create the offline map just in few minutes.

1. Open the software and zoom to the area of your choice. You can add more web maps (e.g. Open See Map if required)

1

2. Set Geometry Bounds for your area

2

3. Zoom-out slightly to see the selected area – you can modify the rectangle if you wish.

3

4. Download OSM data for selected area.

4

5. Wait until the OSM data will be downloaded from the server:

5

6. Ones the data is downloaded remove Web map (OSM Mapnik) from the map viewer – this is not necessary, but will speed up the generation of the tiles.

6

7. If you like Hill Shading – you can apply the preset template. The necessary high data will be automatically downloaded.

7

8

8. If you need you can add contours to your map as well.

1

9. Ones you are happy with the map, you can zoom-in or pan around to check the details you need to generate the offline tiles. This operation may take a while and depends from various factors like the performance of the PC, selected zoom-levels etc.

10

You can read more about the consequences of the zoom-level selected here.

I would strongly recommend that you do not use zoom levels above 17 when creating offline tiles. Usually level 16 or 17 is enough for most activities.

When you are happy with all the map settings please follow this guide to generate the mbtiles file.

Basically you need to run a command like:

generate-mbtiles minzoom=0 maxzoom=17

From my our personal experience is better that you generate more smaller files than one big one for huge area, however it’s entirely up to you and you may prefer other options.

The generated file will be located in the Tiles folder, you can rename it before copying it over to device SD card:

13

14

10. The offline map can be set as default using the extension and used without Internet connection.

Screenshot_2015-02-14-03-04-18 Screenshot_2015-02-14-02-58-52

Screenshot_2015-02-14-03-00-31

Generating mbtiles from an image

In number of emails I have been asked how to create an offline map from geo-referenced image. Please follow this article to create .mbtiles file ready to use with MapIt from an image. We use open source software to achieve the goal.

You need to have:

Please follow the steps below to get the offline map of Kilimanjaro in format compatible with MapIt:

1. Open qGIS and open a Georeferencer plugin as shown below:

qGIS Georeferencer plugin
qGIS Georeferencer plugin

2. Add your image to the plugin and set the spatial reference – you can use filter typing 4326 in the filter box.

Choose WGS84  spatial reference for your image
Choose WGS84 spatial reference for your image

3. Selecting georeferencing points.

Depending from the type of image you may use 4 or more points to georeference an image.
Zoom to the upper right corner and add point then enter longitude and latitude of that location:

Add lat, lon for the image corner.
Add lat, lon for the image corner.

Add another 3 points. Please make sure, that your working diagonally. In our example it would be: upper left, lower right, upper right, lower left. This will minimize problems according to the visibility of the map during georeferencing it.

Georeferencing points added to the image.
Georeferencing points added to the image.

4. Transformation settings

Before we georeference the image please go to Settings and set Transformation settings as shown on the picture below:

Georeference an image - transformation settings
Georeference an image – transformation settings

5. Georeference the image and add it to qGIS map view to check out if everything is fine.  Go to the used crossings of longitudes and latitudes and compare the shown coordinates with the desired coordinates. If they fit, you are done and ready for next step.

6. Before we use the image in Maperitive we need to convert the wld file (created during the georeference process above in the same location as the image) to georef file used by Maperitive.

Make sure that the number of decimal digits for the cell size is not>17 in georef file, otherwise Maperitive will complain.

Conversion of world file (wld) to georef file
Conversion of world file (wld) to georef file

World file content:

0.00012082694840728
0
0
-0.00012226615739132
37.11882655590969193
-2.90009944643156192

georef file content:

<georef>
<srs>
<id>EPSG:4326</id>
</srs>
<origin>
<x>37.11882655590969193
</x>
<y>-2.90009944643156192
</y>
</origin>
<cell-width>0.00012082694840728
</cell-width>
<cell-height>-0.000122266157391
</cell-height>
</georef>

8. Open Maperitive and type command:

clear-map

then

load-image file=Data\kilimanjaro.png background=false 

Maperitive load-image
Maperitive load-image
Georeferenced file loaded to Maperitive
Georeferenced file loaded to Maperitive

9. Generate .mbtiles file – please type the command below changing the zoom levels if necessary:

generate-mbtiles minzoom=0 maxzoom=15

Generate mbtiles
Generate mbtiles

10. rename the generated file to whatever name you want:

rename

11. Copy the file to the device memory card to MapIt->OfflineMaps folder:

phone offlinemaps

12. If you have MapIt offline maps extension your map will be available and ready to use – enjoy…

Offline Map within MapIt app.
Offline Map within MapIt app.

MapPad app is growing

Hi, It’s been a while since I have posted anything. Just to let you know that MapPad project has grown significantly in the past year, lots of new functions have been added and you can get the app demo for free here.

The most recent update includes WMS and ArcGIS Server Tiled services support, you can add your own Google Maps overlay and improve your productivity even more:

http://mappadapp.com/adding-custom-wms-service

http://mappadapp.com/google-maps-overlays

Enjoy 🙂