I think the problem could be with the range of values in your original image. You can use the -scale
parameter in gdal_translate
to get images within the range of an 8 bit image.
For example
gdal_translate -of PNG -ot Byte -scale in_tiff.tif out_png_scaled.png
This will automatically set the input minimum and maximum values used to scale, if these don't work you can specify a minimum and maximum value after -scale
.
If you need to make the image smaller you can also resize with gdal_translate
using -outsize
. For example, -outsize 50% 50%
will resize to 50 % of the original.
The black border on the edge of your imagery is the result of the JPG or WebP encoding Mapbox uses as the default image format for raster tiles. JPG images are generally a smaller and faster image format, but we also make PNG images available to support transparency around the edges of your image, however, Mapbox Studio doesn't support PNGs as an image format directly in the editor.
You can use PNG images with both Mapbox.js and Mapbox GL JS, though the process is a bit different for each.
For Mapbox.js projects:
L.mapbox.tileLayer('map.id', {
format: 'png256'
}).addTo(map);
If you are using Mapbox GL JS, you will need to make some manual edits to your JSON file to point to the raster source as a png layer. See this example for details. Also, GL JS will use WebP if the browser supports it (only Chrome), otherwise it will use JPEG.
If you are still seeing the black border, you may need ensure the TIFF image was properly exported with the NODATA values. To do this, use GDAL and the following command:
gdal_translate -of GTiff -a_nodata 0 input.tif output.tif`
Best Answer
You can make your image significantly smaller by converting it into a single-band paletted tiff with rgb2pct.py. Moreover, you can continue and reduce the bit depth of the single band tiff with gdal_translate by using the GeoTIFF creation option "nbits" as documented in http://www.gdal.org/frmt_gtiff.html. Using compression will reduce the file size further.
I made a simple test with the following commands
Here are the file sizes of the original file and the three processed files