3

I have an hillshade tiff for which the current band type=Bytemay be problematic.

How to change the band type to type=float ?

Hugolpz
  • 2,653
  • 3
  • 26
  • 51

2 Answers2

5

Try:

gdal_translate -of GTiff -ot Float32 input.tif output.tif

Seems you can choose between several float types: "Byte"/"Int16"/"UInt16"/"UInt32"/"Int32"/"Float32"/"Float64"/"CInt16"/"CInt32"/"CFloat32"/"CFloat64"

Ismael Olea
  • 97
  • 1
  • 5
  • 1
    The answer has been edited but was initially correct: the float supported types are Float32/Float64/CFloat32/CFloat64. – Ismael Olea Mar 12 '19 at 20:31
3

With gdal_calc.py is, for example, --type Float32 (my answer based in your link). The next command worked for me when I used to calculate at-satellite brightness temperature:

gdal_calc.py -A b6.rad.tif --calc "1260.56/log((607.76/A)+1)" --type Float32 --outfile bright_temp.tif

I hope that helps.

xunilk
  • 29,891
  • 4
  • 41
  • 80
  • Did you tested it ? --type='Float32' clearly fails for me. – Hugolpz May 22 '15 at 18:03
  • Of course. The above example was in my system with Ubuntu. In Debian, you can see my answer here: http://gis.stackexchange.com/questions/147457/raster-caculator-qgis-2-6-v-s-gdal-calc-py-by-terminal/147492#147492 – xunilk May 22 '15 at 20:16
  • If you have problems with gdal_cal.py the script is here: http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/gdal_calc.py. I copied it in an older Ubuntu system in /usr/bin and it worked nicely (I know that you use Linux for a recently question). – xunilk May 22 '15 at 20:28
  • I indeed run on ubuntu. I used srtm tif, gdal hillshade, then gdal_calc with type=Float32, it fails. When --calc=<equation> is more basic, it behave as expected. – Hugolpz May 23 '15 at 07:33