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!

1 Answer 1


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.

  • Yes, that's what i usually do, too. But as i read the question, i thought, that you also can try to Import those Scripts to get more control over the process. Commented Nov 19, 2019 at 7:28
  • Yes Andreas, after GDAL 2.0.0 you can directly call some functions (without the need of using subprocess) but not all of them (including gdal_edit, gdal_merge, etc.)
    – Sinooshka
    Commented Nov 19, 2019 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.