Using GeoTIFFs for Offline Maps
Many local government agencies maintain awesome datasets of aerial photography, and publish that imagery under flexible or public domain license to enable easy use for many different types of applications. Fulcrum supports the MBTiles format for offline map packages, so it’s useful to know how to take the up-to-date, hi-res imagery available in GeoTIFFs for your project area, and build maps to use in the field. In this post I’ll walk through downloading and converting some aerial photos, then loading them into TileMill to create offline maps, including a video walkthrough on how to create them.
Download some imagery
The first step to get yourself rolling with custom offline maps is to download some imagery. In my example, I’ll download a sample project area from Mesa County, CO, since they have a nice browseable interface for finding and downloading imagery sections cell by cell, so I can grab the pieces for my exact project area. The area I’ve downloaded is along the banks of the Colorado River, just southwest of Palisades, CO. The total area I wanted ended up being 8 separate GeoTIFF images, each about 80 MB in size. The images are 6-inch resolution, which is excellent quality for field mapping using Fulcrum.
Once I’ve got my raw imagery downloaded, I need to do some processing on it to get it ready to convert to MBTiles.
Getting set up
We’re going to use the powerful GDAL library to process the imagery. GDAL is an open source map data processing package with tools for working with both raster and vector data (using the
ogr suite of tools). We only need the GDAL imagery processing components called
gdal_merge to combine the separate images into one mosaic, and
gdalwarp to reproject.
If you don’t already have GDAL installed, you can download ready-to-use packages from the website for all platforms, including Windows, Mac, and Linux. The installers are pretty straightforward. Test that you have the library set up by opening a command line window (Terminal on Mac or the OSGeo4W program on Windows) and running the command
gdalinfo --version. This should print out the current version of the program, indicating it’s properly installed.
Merging our images
The first processing step is to get my 8 separate
.tif files merged into a single one. To do this, we’ll use the
gdal_merge utility, which can stitch together many separate files into a single whole. You need to pass it the list of images to merge, with the
-o option to set the output file of your merged imagery:
Now I’ve got a file called
riverbend.tif that’s ready to get reprojected to bring into TileMill.
This step can be tricky depending on your original datasource. When using TileMill to produce the MBTiles dataset, you’ll need to know the original source projection of your data (the EPSG code) in order to get it to display for export. There’s a command called
gdalinfo that can help you out here if your data’s projection metadata isn’t published along with the data. There’s a helpful site called spatialreference.org that I’ve used for years to search and look up the proper codes.
The Mesa County data is UTM NAD83. Running a quick search, I find out the proper code:
EPSG:3742. Once I have this, I can use the
gdalwarp command to reproject my data to the web-friendly web mercator format:
gdalwarp -s_srs EPSG:3742 -t_srs EPSG:3857 riverbend.tif riverbend-3857.tif
The GDAL stack of tools has a ton of other powerful functionality under the hood if you’re curious. Mapbox has some additional documentation that you might find helpful.
Load into TileMill
TileMill is a tool for creating your own MBTiles maps, which is free and ready to use on Windows, Mac, or Linux. All we need to do in TileMill is load a single
.tif file and generate an MBTiles map export. There are several steps to get your data loaded into TileMill and set up for proper export, so watch this quick video walkthrough showing how that’s done:
Once you’ve got your exported MBTiles file (mine ended up at about 150 MB for the map in the video example), I can upload to Fulcrum so it’s available to all of my field staff to download from the cloud and cache to their devices to use offline and disconnected.
With a few Google searches, you can find if your local area of interest publishes aerial imagery like this to use offline for your own projects. Another tool for building MBTiles maps from all sorts of data types is MapTiler, a commercial tool that’s powerful if you need to generate lots of map packages. MapTiler also has a simple mobile app (if you’re just looking for viewing on mobile for iOS) that lets you load your MBTiles maps to an iPhone or iPad via Dropbox. Really handy for quick reference needs.
GDAL supports tons of raster formats in addition to GeoTIFF, so you could go through this process with files in formats like MrSID, JPEG, PNG, ECW, and more.
Check our our help guides for uploading MBTiles maps to your Fulcrum account, which publishes your maps for field data collectors to download and use offline. If you’re looking to do more powerful processing on imagery, check out these guides on image compositing and color correction, also.