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

Advertisements

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.

MapIt – GIS data collector

Last 6 months I have been working on new app. MapIt is now officially out, and available on Google Play, check it out. I am looking for feedback.

MapIt is a survey application. It’s excellent survey tool for any kind of GPS surveys and map based surveys. Spatial data collection (supported points, lines and polygons), asset management and asset surveys can be done faster and in more efficient way.
MapIt can be also used as a quick measurement tool to calculate area or distance.
When registering location simply choose required attributes from defined earlier drop-down list, no need to type the same information over and over again. Import long attributes list from text files if necessary and use them in number of projects. If necessary you can add one or more pictures to each location as well.

If you are you working in the field, gathering large amount of spatial/location based data this app is for you.
Map It is a very useful tool for anyone involved in forestry, agriculture, environmental or farming business and allows quick collection of spatial data without the need of typing similar information number of times.
Speed up your workflow and make the data collection more efficient. Take advantage of survey layers and possibility to reuse same set of attributes for multiple surveys. Export your data to common files like CSV, KML, GeoJSON, ArcGIS JSON and process them further using Desktop GIS software like ArcGIS, ArcGIS Online or open source QGIS and other professional tools like MS Office.

Please visit our website and follow a Walk-Through (sample tree’s survey) to understand better the application workflow.

Support for several global and local coordinate systems: WGS84 (decimal or degrees), Web Mercator, British National Grid, UTM SAD69 (Brazil), UTM NAD83, NATO, Stereo 70 (Romania), System 1992 (Poland), UTM Indian 1975 (Thailand), SIRGAS 2000 UTM coordinate system for South & Latin America, ETRS89 TM06 – Portugal, D73 Modified Portuguese Grid – if you require support for any other spatial reference please get in touch.
Selected features:
– Base maps: Google Maps, Bing Maps, Open Street Map, Mapbox and Offline mbtiles,
– Support for WMS and ArcGIS Server Tiled map services as Google Maps Overlays (Topographic maps, orthophoto maps, geological surveys, cadastral information and number of other country specific free services can be used now together with Google maps as an overlay),
– Possibility to create and maintain sets of attributes – these are available as a drop down lists when new feature is being recorded, long lists of values can be imported from text files.
– Clusters for map markers, efficient way of having large number of points on the map without performance issues,
– Currently 2 methods of collection are supported (GPS location, Map cursor location),
– Possibility to group your data into the survey layers – each survey layer may have a default set of attributes.
– Local SD card export or share option. At the moment KML, CSV, GeoJSON, ArcGIS JSON export is supported,
– Possibility to record multiple points, polylines and polygons on one layer,
– When creating new polygon or line features measurement details like area or length are also available.
– GPS and satellites status,
– Address, location search,
– Import point, line or polygon features into layer from CSV, KML or geojson files.
– Import attributes’ values from file
Our users are successfully using MapIt in number of applications including:
– environmental surveys,
– woodland surveys,
– forestry planning and woodland management surveys,
– agriculture and soils’ types surveys,
– road constructions,
– land surveying,
– solar panels applications,
– roofing and fencing,
– tree surveys,
– GPS surveying,
– site surveying and soil samples gathering