Could someone navigate me for using/calling GDAL stand-alone programs from Python? I have GDAL 2.3.2 and Python 3.7. When I call gdal from python I can access to a limited number of functions including gdal.Warp() and gdal.Translate(). I can not however access 'gdal_edit' which I am currently interested to use. In the Git page of this function I did not find any information regarding access to this function either!
gdal_edit is itself a python script - you should be able to find it located within your GDAL installation.
To access it from Python, you can use the subprocess library to call the script. e.g.
import subprocess as sp #locate your gdal_edit script gdaledit = r"C:\Program Files\GDAL\gdal_edit.py" #input data srcdata = 'abc.tif' cmd = [gdaledit, '-a_srs', 'EPSG:4326', '-tr', '150', srcdata] sp.check_call(cmd, shell=True)
You use the
shell=True argument so that Python can effectively run the script from the command line. Without it, you will get an error.