Skip to content

Use Mapbox and display a styled carbon density layer

Sifeddine Biri requested to merge mapbox into main

Description 

Use Mapbox to display the carbon densities layer in colors that correspond to the legend style. The web map is set to the default raster projection, albers.

Steps

  1. The initial carbon-no-w.tif layer was styled with QGIS Symbology using the Viridis color map and exported as color-carbon.tif.

  2. Turn the big raster file into a set of smaller, web-friendly tiles. This effectively creates a single SQLite database file that houses all the tiles.

gdal_translate -of MBTILES -co "TILE_FORMAT=PNG" -co "ZOOM_LEVEL_STRATEGY=AUTO" -co "RESAMPLING=BILINEAR" color-carbon.tif color-carbon.mbtiles

  1. Add extra, lower-resolution versions of the map so that it loads faster when zoomed out.

gdaladdo -r average color-carbon.mbtiles

  1. Ensure that all of the map's tiles and metadata are in place.

mbtiles validate --agg-hash update color-carbon.mbtiles

A ready-made color-carbon.mbtiles file was uploaded to project Google Drive.

Test: 

Assumes martin is running locally on port 3000 serving the tiles with: martin /path/to/color-carbon.mbtiles

map-carbon

Edited by Oliver Baldwin Edwards

Merge request reports