1

I'm trying to merge large raster files (DEM's) together but I run into memory errors using the 'Raster Merge' tool in QGIS 3.8.

I suspect the issue is mainly the high amount of precision in the float32 data format for each pixel. Therefore if I could translate/convert the format into half/float16 format I should be able to do this.

Unfortunately I don't see an option to export GeoTIFF's into this format in the 'Raster Translate' tool or otherwise.

Edit: I need a few decimal places of precision - ideally 3. The rasters are DEM's that are accurate to about 8-10cm, so any decimals past 3 are nonsense and just eat up memory.

underdark
  • 84,148
  • 21
  • 231
  • 413
Matt Canada
  • 143
  • 8
  • 2
    16-bit float doesn't appear to be an exceedingly useful format, with just three places of accuracy (1/3 is 0.333251953125). In theory, GDAL 2.2 and higher support it, but most DEMs I've ever used were signed 16-bit, so truncating values for no storage gain doesn''t seem like a likely solution. This appears to be an XY Problem, where your question is about an unlikely implementation instead of the root problem (memory errors). You would likely get a better solution by changing the question. – Vince Jul 25 '19 at 18:28
  • 1
    Perhaps you could create a virtual raster: https://gis.stackexchange.com/q/25499/81764 – csk Jul 25 '19 at 20:27

2 Answers2

2

There is a DISCARD_LSB option for GeoTIFFs that could be useful in conjunction with compression. For example the following call will compress input.tif to output.tif using the DEFLATE algorithm with a floating point predictor (2) and discard the 2 least significant bits:

gdal_translate input.tif output.tif -co COMPRESS=DEFLATE -co PREDICTOR=2 DISCARD_LSB=2
Rich
  • 1,589
  • 2
  • 13
  • 36
2

For gdal version >= 2.2, there is an option NBITS=16 to get half-precision floating point output. So, something like:

gdal_translate -co NBITS=16 input.tif output.tif
Jvg
  • 143
  • 8