When uploading a GeoTIFF file to Mapbox to create a tileset, it is being displayed in Black and White? I would expect it to have the same colors as the TIFF when viewed in any other viewer?

How do you create a tileset with a GeoTIFF to use it as a base map in MapBox?

My ultimate goal is to use this GeoTIFF and then dynamically lay lat/long points on it, but I need to get the map looking correct first.

Seems to work just fine in QGIS.

  • Is your GeoTIFF using RGB bands or is it a single band with indexed/palatte colours? You might need to expand it to RGB. See gdal_translate's -expand option. Commented May 10, 2020 at 6:52

2 Answers 2


The following commands can be used to translate the GeoTIFF file. This information was obtained by MapBox support.

  1. this will leave you with a raster tile with a black background.

gdal_translate -co TILED=TRUE -co COMPRESS=LZW -co BIGTIFF=YES -expand RGB INPUT.tif OUTPUT.tif

  1. Make your raster tile transparent

rio calc "(asarray (take a 1) (take a 2) (take a 3))" --co compress=lzw --co tiled=true --co blockxsize=256 --co blockysize=256 --name a=INPUT.tif OUTPUT.tif

  1. Make NoData values to zero.

rio edit-info --nodata 0 INPUT.tif

Before Conversion

enter image description here

After Conversion enter image description here


If you're using R / raster package for this, you need to do two things:

  1. Set colNA option of RGB to "black".
  2. On raster write, set NAflag to 0.

For instance:


rgb_raster <- RGB(a_raster, colNA='black')

# Not sure if these are needed, but match the official example


The writeRaster call needs to be done separate from the RGB call because an error results if you set datatype there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.