Closed iiepdev closed 3 years ago
GDAL Raster calculator
@iiepdev you must try the same operation/command from the command line: do you get the same results? be sure you are using the same GDAL version/installation being used by QGIS.
GDAL Raster calculator
@iiepdev you must try the same operation/command from the command line: do you get the same results? be sure you are using the same GDAL version/installation being used by QGIS.
Thank you @gioman
I have never used GDAL from the command line. I imagine you mean to run this command from the OSGeo4W Shell or from the Command prompt, using the GDAL/OGR console call command (which for this case is: gdal_calc --calc "(A - amin(A))/(amax(A) - amin(A))*100" --format GTiff --type Float32 -A "C:/Users/g.vargas/BOX/IIEP_MyProjects/MP_01000298_RND_SDA/WorkFiles_Experts/298-Issue-Papers/298-Issue-Paper-UNOSAT/Geospatial Data - Part A/Part A/Raster Data/Hazard_Volcano_Aceh.tif" --A_band 1 --outfile C:/Users/g.vargas/AppData/Local/Temp/processing_MqvAmr/0713417ed361418f9af6f1e4d3f3ef6c/OUTPUT.tif).
When I try to run either option it doesn't recognize the command, which means I might need to install the python bindings for GDAL? (https://stackoverflow.com/questions/61901761/running-gdal-from-the-command-line-on-windows-10-x64)
Am I missing something?
@iiepdev yes the command is the one you refer, you must change it a little to be able to run it from the CLI manually, example:
gdal_calc --calc "(A - amin(A))/(amax(A) - amin(A))*100" --format GTiff --type Float32 -A "C:/Users/g.vargas/BOX/IIEP_MyProjects/MP_01000298_RND_SDA/WorkFiles_Experts/298-Issue-Papers/298-Issue-Paper-UNOSAT/Geospatial Data - Part A/Part A/Raster Data/Hazard_Volcano_Aceh.tif" --A_band 1 --outfile C:/Users/g.vargas/BOX/IIEP_MyProjects/MP_01000298_RND_SDA/WorkFiles_Experts/298-Issue-Papers/298-Issue-Paper-UNOSAT/Geospatial Data - Part A/Part A/OUTPUT.tif
When I try to run either option it doesn't recognize the command, which means I might need to install the python bindings for GDAL? (https://stackoverflow.com/questions/61901761/running-gdal-from-the-command-line-on-windows-10-x64)
no, just open the "ogseo4w" shell and run the command from it. That shell shortcut is inside the "QGIS" group that the QGIS installer created in the start menu of your Windows.
The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue. In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue. If there is no further activity on this issue, it will be closed in a week.
While we hate to see this happen, this issue has been automatically closed because it has not had any activity in the last 42 days despite being marked as feedback. If this issue should be reconsidered, please follow the guidelines in the previous comment and reopen this issue. Or, if you have any further questions, there are also further support channels that can help you.
Describe the bug
I am using GDAL Raster calculator to automatically reclassify Raster layers so that regardless of their initial values, they are transformed to be between 0 and 1 (or 0 and 100, as needed).
Since this needs to happen within a Graphical model, the algorithm needs to be able to automatically detect the minimum and maximum values within each Raster, and then make the following transformation:
NewRasterValue = (RasterValue - min(RasterValue))/(max(RasterValue) - min(RasterValue))
This will automatically shift the distribution to be bounded by 0 and 1 (and can be then multiplied by 100 to be scaled to be 0 to 100).
To achieve this I'm using the GDAL Raster calculator, with the following parameters:
Input layer A: Raster file Number of raster band for A: Band 1 Calculation in gdalnumeric syntax using +-/ or any numpy array functions: (A - amin(A))/(amax(A) - amin(A))100 Output raster type: Float32
When I do this for some raster files, I get the expected results. However, with some other layers the GDAL Raster calculator outputs a raster where every pixel is equal to 1 (or to a 100, in the case of the equation above).
How to Reproduce
QGIS and OS versions
Additional context