A github tile server

Display small maps dynamically

In much of my work our work we use geospatial data (either vector or raster maps). However, visualizing this data easily for people unfamiliar with geographic information system (GIS) toolsets is often difficult as end users care about the result (a nice map) not learning visualization tools. In short, to communicate your work we need to present maps in an appealing way.

There are commercial options to do so, most prominently Mapbox. Mapbox does have a free option, but this obviously only stretches so far and a subscription service is not cost effective for only intermittent use.

An other option we want to present here is using github as a fast and easy way to host map tiles and host a micro-website, by using QGis and the Qtiles plugin.

The basic procedure would be to load your mapdata into QGis, install the QTiles plugin, and run the plugin to build map tiles. Make sure to activate the “write leaflet-based viewer” option. This will generate a folder with a map tiles pyramid and an html file to render a leaflet map. You can specify the number of zoom levels included and the size and data format of the tiles. Most defaults work well, but we suggest to increase the file dimensions to reduce the number of tiles generated.

Once done you upload the data to github as you would with any other project and point the leaflet code to your project location (replace the CAPITALIZED text with your personal parameters and render settings in the generated html file below to use your github project).

var mytile = L.tileLayer('https://github.com/YOUR_GITHUB_HANDLE/PROJECT_NAME/raw/master/TILES_FOLDER/{z}/{x}/{y}.png', {
        maxZoom: 8,
	minZoom: 5,
        tms: false
      }).addTo(map);

For one of our projects mapping long-term changes in forest cover and structure for the central Congo Basin we used such a micro-site approach.

Avatar
Koen Hufkens, PhD
Partner, Researcher

As an earth system scientist and ecologist I model ecosystem processes.

Related

Next
Previous