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 grater than 17 digits 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>

 

Important:

Please note that the file name must be kilimanjaro.png.georef unless you have your images in different format eg. bmp.georef or jpg.georef etc.
Both files PNG and png.georef need to be copied to Maperitive/Data folder.

 

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.

osedok

If you can’t explain it simply, you don’t understand it well enough.

Albert Einstein

11 Responses

  1. Runge says:

    Hi!
    Thank you very much for a such informative article.
    By the way, you can also generate a mbtiles tile set from different data sources using MapSurfer.NET – a free and advanced cartographic framework.

  2. Glad my Kili map was useful. 🙂

  3. Lukáš says:

    Hi,

    I am not able to find my OfflineMaps folder. If I create it and place my mbtiles into it, MapIt cannot find the files. 🙁

    Lukas

    • Rob V. says:

      In his Android MBTiles app, he says to put it in “MbTilesMap->Resources->Maps”. Is that helpful? I did not see that above.

      • osedok says:

        MbTiles Map is a different app. For MapIt you should have your mbtiles in MapIt->OfflineMaps folder. The folder is being generated automatically when the app is starting for the first time, if is not visible on PC, sometimes restarting the phone/tablet helps to discover new folders. If you have still problem please copy the file to the root of SD card and than move the file using file manager on the phone/tablet to MapIt->OfflineMaps

  4. paulo says:

    i made my own georeferenced image but a can´t load in console. when I try, show the msg file “no exist”, I need to create a folder to my data in special in place or set directory in maperitive?

    • osedok says:

      Hi Paulo, I am not sure as I am not working with Maperitive on the daily bases – please refer to the guide or contact the Maperitive team for support. I will have a look when have got more time, but cannot remember right now.

  1. September 16, 2015

    […] Create mbtiles file using your favorite method e.g. following the steps on this page. […]

Leave a Reply