Feature request #4475

Add Data Type to Raster Calculator

Added by alobo - over 5 years ago. Updated over 4 years ago.

Status:Feedback Start Date:11/01/2011
Priority:Normal Due date:
Assigned to:Marco Hugentobler % Done:

0%

Category:Rasters
Target version:Future Release - Nice to have
Platform:all Resolution:
Platform version: Pull Request or Patch supplied:Yes
Status info: Tag:

Description

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

patchRastCalc (21.8 kB) Zdenek Ruzicka, 11/23/2011 05:56 am

History

Updated by Tim Sutton over 5 years ago

  • Target version changed from Version 1.7.1 to Version 1.7.2

Updated by Zdenek Ruzicka over 5 years ago

Hi, I have tried to write patch.

Updated by Giovanni Manghi over 5 years ago

  • Pull Request or Patch supplied changed from No to Yes

Updated by Richard Duivenvoorde over 5 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.

Updated by Zdenek Ruzicka over 5 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.

Updated by Zdenek Ruzicka over 5 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").

Updated by Giovanni Manghi over 5 years ago

Can someone review the attached patch?

Updated by Richard Duivenvoorde over 5 years ago

I tested it (see #4) and found some issues. But I cannot answer the question of Zdenek.

Maybe he (or we) can ask the question on the devlist? And then based on that he can do an updated patch?

Updated by Marco Hugentobler about 5 years ago

  • Assigned to set to Marco Hugentobler

Updated by Marco Hugentobler about 5 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:

float* calcData;
.....
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.

Updated by Zdenek Ruzicka about 5 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.

Updated by Giovanni Manghi almost 5 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

Updated by Pirmin Kalberer over 4 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

Also available in: Atom