Feature request #4475
Add Data Type to Raster Calculator
|Pull Request or Patch supplied:||Yes||Resolution:|
The former plugin Raster Calc had the option of selecting a given Data Type (i.e Int16, Float32 etc)
for the output. This was most useful and is not present in the current Raster Calculator
#4 Updated by Richard Duivenvoorde about 6 years ago
- Status changed from Open to Feedback
- Target version changed from Version 1.7.2 to Version 1.8.0
Hi Zdenek, thanks for the patch! thought to give the patch a try :-)
Gui looks nice (maybe a little less wider?)
Trying the datatype dropdown on a ecw I have here (I'm no rasterman...), selecting certain types from the dropdown will more or less hang qgis, showing zillion of warnings in the debug window:
"Warning: GDAL data type is not supported " (eg with the type CInt32).
Is the elements of the Pixel format dropdown dynamic? I mean, should it maybe be checked by the underlying lib which types are available or so? Or maybe testing after one pixel if there is this warning and then come back with some message to optionally break off?
Please let us know if you find time to have a look in it, otherwise maybe somebody else should have a look into it.
#5 Updated by Zdenek Ruzicka almost 6 years ago
Hi Richard, thanks for trying.
Elements of the Pixel format dropdown are chosen dynamically from metadata of each driver (using GDALGetMetadataItem( ) and look for GDAL_DMD_CREATIONDATATYPES), only if in metadata is nothing about supported pixel data types, it show you all GDAL supported pixel data formats.
It looks that there is some problem with that complex pixel data types, Raster Calculator write into the file, problem 'begin' during opening it :). It looks that gdalinfo has no problem with it. I tried save data using python plugin RasterCalc and there is same problem.
I will look at it more in deep.
#6 Updated by Zdenek Ruzicka almost 6 years ago
Does QGIS support rastar data saved in complex pixel data types (eg CFloat32) at all?
I am asking, because I tried open file which I created using Raster Calculator (GeoTIFF,CFloat32) and opened it in Grass with success. And I also made GeoTIFF with CFloat32 pixel data format using Grass and I can't open it in QGIS (same warnings: "Warning: GDAL data type is not supported").
#10 Updated by Marco Hugentobler almost 6 years ago
The patch looks good and adds important functionality to the raster calculator.
There is however one problem with the patch. The GDAL doc says that the array passed to RasterIO for writing needs to have output type. With the patch, calcData is still hardcoded float*, even though the output type can be different:
GDALDataType pixelFormatDGT = GDALGetDataTypeByName( mOutputPixelFormat.toLocal8Bit().data() );
if ( GDALRasterIO( outputRasterBand, GF_Write, 0, i, mNumOutputColumns, 1, calcData, mNumOutputColumns, 1, pixelFormatDGT, 0, 0 ) != CE_None )
It would be great if you could improve that part of the patch.
#11 Updated by Zdenek Ruzicka almost 6 years ago
Thanks, I will look at this (float* calcData;...).
But still I am not sure whether QGIS can read rastar data saved in complex pixel data types (eg CFloat32). I made one file using gdal_translate (gdal_translate -ot CFloat32 -of GTiff elevation.tif elevationGDAL_CFloat32.tif) and still I can't open it in QGIS.