Skip to main content

I’m trying to upload a raster to Mapbox, but no matter what I do, the output file always turns the nodata cells to black. I have tried fixing this using RasterBandNodataSetter and RasterPaletteResolver. If I look at the feature cached output from those transformers the nodata cells are still transparent. The issue arises when I use the MBTILES writer. No matter what, it writes nodata as black. I also tried removing the nodata (RasterBandNodataRemover), doesn’t work. I have tried outputting the data both as png, png8, and jpeg. Does anyone have any other suggestions? Thank you in advance!

Hi @tara_he could you send a screenshot of what your MBTILES writer parameters look like? Specifically, which compression setting do you have: PNG or JPEG? This may have an impact on how your no-data values are displayed. If you have anything else you can share with us we might be able to look into it further. There doesn’t seem to be any documentation on how no-data is displayed in the output, only that “any values are accepted; however,] all bands on a raster must have the same value”. 


Thanks for the offer of help @evieatsafe. Here is what I currently have.

I have tried PNG, PNG8, and JPEG, but I haven’t changed the PNG Compression Levels. All of my nodata cells have a value of 0 as defined by a Raster BandNodataSetter. When I have tried writing to JPEG, I do need to also use a RasterPaletteResolver. That is not necessary on PNG though. Thank you again. 


Hi @tara_he I got some advice from a colleague and neither PNG or JPEG are great with transparency (especially JPEG). They suggest that you might have better luck using an alpha band instead of nodata values for representing the invalid parts of the raster. However, Alpha is not supported by JPEG so you will need to use PNG. You can generate an alpha band from nodata by using a RasterInterpretationCoercer or RasterPaletteInterpretationCoercer (especially if you have paletted data, which it sounds like you do) with the following settings:

  • Destination Interpretation Type = RGBA32
  • RGB to RGBA = Create alpha band from nodata

Let us know if this has different or desired results! 


That was it @evieatsafe! It makes so much sense now… I can’t believe I didn’t think of that before. I truly appreciate you and your colleague’s help. Oh, and yes, my data is paletted so I did need to use the RasterPaletteInterpretationCoercer. I honestly didn’t understand what that transformer even did. I’m so excited this is figured out. Thank you again!!


Reply