GDAL Calc Windows – How to Setup GDAL Calc for Command Line Use on Windows

gdalpythonqgiswindows

I've searched the web extensively (e.g. here) but I am not able to find any documentation on how to setup gdal_cal.py.

When I try to run gdal_calc.py from my command line e.g.:

gdal_calc.py -A input1.tif -B input2.tif –outfile=result.tif
–calc="A+B"

i simply get prompted with which program i want to open the file.
how do i setup up gdal_calc.py so that I can run it from my command line? Or where can i find documentation about it.

INFO:

  • i have newest version of python
  • i have newest version of QGIS (3.0)
  • i have newest version of python (2.7.14)(using spyder IDE(3.2.6))
  • i have newest version of GDAL (2.2.4)
  • running on windows

Best Answer

If you have OSGeo4W installed (which normally comes with QGIS) You can "directly" run gdal_calc.py with the OSGeo4W shell from the windows command shell by using something like:

C:\Program Files\QGIS 3.6>OSGeo4W.bat gdal_calc -help

Or you can also use the OSGeo4W Shell:

Start first the OSGeo4W Shell from the installed programs menu.

enter image description here

The list that you get with o-help contains gdal_calc

enter image description here

And you can start gdal_calc simply with "gdal_calc"

enter image description here