2

I have been using python to turn a netcdf into a geotiff. Once I have the geotiff, I am using gdalwarp to transfer it into the right projection. Then use gdal_translate to get the tif into a vrt file.

I then use the vrt with gdal2tiles.

The problem is, when I get my tiles, I end up with my NoData showing up as the bottom or top of my color ramp. In the image shown, I set NoData to be 0.

I have tried adding a color ramp two different ways, one with a color-relief using gdaldem. When I do that, I get a

Error : band 1 has no color table

from gdal_translate. I have also used python to set the ColorTable.

All I want is for my NoData to be transparent. Any idea on how to do that?

EDIT: How I create my array, I then use osgeo to make the tif.

noData = array == fill_val norm_array = array.copy() norm_array[noData] = 0

I have tried many different options once I have the tif,

gdalwarp -overwrite -ts 1736 932 -s_srs EPSG:4326 -t_srs EPSG:3857 -srcnodata 0 -dstnodata 0 -dstalpha original.tif warpped.tif

I have also tried using the -a_nodata for gdal_translate and the -a option for gdal2tiler as well. None of that seems to be working.

  • Have you told the gdal utilities what your NoData value is? Please edit your question to show the commands you used. – user2856 Apr 7 '16 at 2:53
  • How are you going from NetCDF to Geotif? I use a numpy.ma.core.MaskedArray when processing NetCDF data in Python: ideally the underlying data already has actual no data values; if not you can use a numpy.ma.masked_where to cast values to null. You might need to cast 0 to null in this step, but I don't know what Geotif does with null/transparent data. – Richard Law Apr 7 '16 at 2:55
  • gdal2tiles.py displays noData cells as transparent for me... it looks like in your image the cells displayed as cream-colored have values of 0. In my original raster I had noData cells defined as "0"... so I used gdal_translate -a_nodata 0 input.tif output.tif to specify the "0" tiles as noData... After using gdalwarp to reproject to 3857 and then running gdal2tiles.py the noData tiles displayed as transparent for me. – jbukoski Jun 2 '16 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.