1

I have a raster layer that resulted from a series of calculations with

  1. raster calculator (simple subtraction of two raster layers)
  2. gdal_translate -ot Int16 -of GTiff ... (convert to Int16, as the result of above is in Float32)

however the gdal_translate command seems to forfeit the No-Data information. It ("correctly") assigns minmal values to the previously no-data cells (−32,768 in case of Int16), however doesn't store the No-Data information in the metadata (as seen in Properties of the raster layer, see picture).

Previous layer, result from raster calculator: RasterLayer properties showing No-Data value (minimal possible value of Float32)

Problematic layer, result from gdal_translate with no No-Data value: RasterLayer properties showing No-Data: n/a

As a result, the values are displayed as regular raster cells by default. I'm aware that I can adjust styling and clip out of range values in styling options to make the "−32,768-No-Data"-cells invisible again. But I'd rather have the raster layer remember, which cell values correspond to "No-Data"!

I tried to assign it with the gdal command: gdal_translate -a_nodata -32.768 -ot Int16 -of GTiff ... however that shows no effect.

Can I manually set a No-Data-Value via Properties or some other tool?

1 Answer 1

2

When saving a raster layer (Right click on layer > Export > Save as ...) you have the option to set No-Data values (see yellow circle in picture). This will have the desired effect.

As an additional hint since we're talking about conversion from Float32 to Int16: Don't forget to check Compression options, since they are not always on by default (see red arrow in picture).

set No-Data value in "Save Raster Layer as..." dialog

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.