Feature request #4475

Add Data Type to Raster Calculator

Added by alobo - about 13 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:Marco Hugentobler
Category:Rasters
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Easy fix?:No Copied to github as #:14402

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, 2011-11-23 05:56 AM

History

#1 Updated by Tim Sutton about 13 years ago

  • Target version changed from Version 1.7.1 to Version 1.7.2

#2 Updated by Zdenek Ruzicka almost 13 years ago

Hi, I have tried to write patch.

#3 Updated by Giovanni Manghi almost 13 years ago

  • Pull Request or Patch supplied changed from No to Yes

#4 Updated by Richard Duivenvoorde almost 13 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 13 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 13 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").

#7 Updated by Giovanni Manghi almost 13 years ago

Can someone review the attached patch?

#8 Updated by Richard Duivenvoorde almost 13 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?

#9 Updated by Marco Hugentobler almost 13 years ago

  • Assignee set to Marco Hugentobler

#10 Updated by Marco Hugentobler almost 13 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.

#11 Updated by Zdenek Ruzicka almost 13 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.

#12 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#13 Updated by Pirmin Kalberer about 12 years ago

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

#14 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No

#15 Updated by Nyall Dawson almost 6 years ago

  • Status changed from Feedback to Closed
  • Description updated (diff)
  • Resolution set to fixed/implemented

This was done in 3.4

Also available in: Atom PDF