Make gdal_calc.py available via the Python API
It would be neat to be able to access gdal_calc.py via
from osgeo import gdal
gdal.Calc(...)
I've seen that the functions are already split in a sensible way in gdal_calc.py. Would you be open to a merge request that moves the code to an importable location while not changing the CLI?
I'm not sure how you could do what you want to do since that would involve mixing gdal_calc.py with the GDAL Python module. But you should already be able to import gdal_calc, and call gdal_calc.doit()
Doing import gdal_calc does not work for me.
gdal_calc.py is located lib/python2.7/site-packages/GDAL-2.4.2-py2.7-linux-x86_64.egg-info/scripts in my environment which is not in the PYTHONPATH
Shouldn't it work to move the needed functions into a module and then import them in https://github.com/OSGeo/gdal/blob/master/gdal/swig/include/python/gdal_python.i#L82 to make them available when the gdal module is generated?
Shouldn't it work to move the needed functions into a module and then import them in https://github.com/OSGeo/gdal/blob/master/gdal/swig/include/python/gdal_python.i#L82 to make them available when the
gdalmodule is generated?
that's a possility. For backward compatibility we'd still want the gdal_calc.py script to be usable (would probably be a few line long script importing the module and excuting gdal.Calc())
Working on a task that will really benefit from gdal.Calc() instead of subprocess.call([sys.executable, 'venv/Scripts/gdal_calc.py'... which is really hard to package in an installer. Was the provision of gdal_calc via the Python API achieved so far?