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:
- Quantum GIS (examples shown in QGIS 2.6)
- a scanned map either in JPG, PNG or a TIFF file (in this example I have used the map of Kilimanjaro available on flickr: https://www.flickr.com/photos/mouser-nerdbot/4696324388/ )
- Maperitive software to generate the .mbtiles file.
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:
2. Add your image to the plugin and set the spatial reference – you can use filter typing 4326 in the filter box.
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 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.
4. Transformation settings
Before we georeference the image please go to Settings and set Transformation settings as shown on the picture below:
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.
World file content:
georef file content:
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:
load-image file=Data\kilimanjaro.png background=false
9. Generate .mbtiles file – please type the command below changing the zoom levels if necessary:
generate-mbtiles minzoom=0 maxzoom=15
10. rename the generated file to whatever name you want:
11. Copy the file to the device memory card to MapIt->OfflineMaps folder:
12. If you have MapIt offline maps extension your map will be available and ready to use – enjoy…
There is also interesting video on YouTube showing how to create the mbtiles from imagery using TileMill.
Alternatively you can use qTile PLugin for qGIS: