[GIS] QGIS’s raster calculator– running as a batch process

batchqgisraster-calculator

I have a series of raster files (150 or so) that I need to multiply by a baseline raster. Unfortunately, the series of rasters have a different cell size (30m×30m i.e. .00027777778 degrees × .00027777778 degrees) than the baseline file (.1 degree × .1 degree).

I ran a test using qgis' raster calculator (which is under the menu path: raster->raster calculator…) and it worked fine as far as I can tell. That is, QGIS was able to reconcile the differing cell sizes and complete the action as expected. However, when I went to batch the process, I discovered its not possible — at least not from the GUI.

When I tried the SAGA, GRASS, and GDAL_CALC algorithms it appears the differing cell sizes are presenting issues. As a note, the basline file currently has a worldwide extent whereas the other files are smaller subsets.

Is there a way to call QGIS' raster calculator as a batch process or from a scripting language?

Example gdal_calculate input:

python gdal_calculate.py --outfile= C:/Users/asd/Documents/MangWork/TestImage/gdalcalcout.tif \
                         --calc "(han*adj)" \
                         --han=C:/Users/asd/Documents/MangWork/TestImage/cl_MEX_30N_110W.tif \
                         --adj=C:/Users/asd/Documents/MangWork/TestImage/Correction_Raster_Comp.tif \
                         --cellsize=MINOF

Best Answer

Why don't you change the cell size of the baseline file? If the resolutions are the same, you will be able to correctly use GRASS (and if it is the same region) or GDAL_CALC. In fact, it is what QGIS probably does before execute the multiplication.

Otherwise, you should consider using the Python Console with the QqgRasterCalculator Class: http://qgis.org/api/classQgsRasterCalculator.html.

Related Question