0

I have a float geotiff raster with values 0, 1 and 2, along with a nodata area. I'm trying to convert the file type do Byte but I'm not being able to preserve the nodata area. It gets converted to 0 and mixed with the data.

Here is the gdal_info of the source dataset

(output from gdalinfo clipped...) 
Center      ( -50.5000000, -14.0000000) ( 50d30' 0.00"W, 14d 0' 0.00"S)
Band 1 Block=4701x1 Type=Float64, ColorInterp=Gray
  NoData Value=255

I then run: gdal_translate -ot Byte teste.tif output.tif

The NoData value gets preserved, as gdalinfo returns

(output from gdalinfo cliped...)
Center      ( -50.5000000, -14.0000000) ( 50d30' 0.00"W, 14d 0' 0.00"S)
Band 1 Block=4701x1 Type=Byte, ColorInterp=Gray
  NoData Value=255

But looking at the image in QGis shows that the nodata area was transformed to 0

Here is the original raster in Float64 format Original raster in Float64 format

And here is what I get after gdal_translate enter image description here

I'm using GDAL 2.2.2 in Ubuntu

  • Are you sure your QGIS display settings aren't the culprit? I.e. nodata is set to a different color than 0? – Jon Aug 6 '18 at 17:56
  • 1
    I'm sure. When I click outside the map, I get value 0 instead of NoData. Meanwhile, I solved my immediate problem using gdalwarp and gdal_edit instead of QGis transform and raster calculator – Daniel Aug 6 '18 at 18:22

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.