gdal.translate via os.system/subprocess

442
1
02-02-2022 12:54 AM
TimDavid
New Contributor

I want to run a gdal.translate command via os.system() or subprocess.run() inside a script.

I tested the following ways of running the command:

  • Directly in the command-line:

https://imgur.com/LWC7Sa3service

  • Starting python from the command-line:

https://imgur.com/AgQtQsq

As you can see it worked fine in both ways. However if I pass the command inside a script it will not work. The following error occurs when I catch the output of the subprocess.run()-Command:

ERROR 1: PROJ: proj_create_from_database: Cannot find proj.db\nERROR 1: Failed to process SRS definition: epsg:25832\n')

I am using Ubuntu and process the data inside a docker-container. The command is executed somewhere deep inside of the command-chain.

0 Kudos
1 Reply
Luke_Pinner
MVP Regular Contributor

Why not use the gdal.Translate python method instead of a subprocess?

You may get more help posting this on GIS Stack Exchange, this is an ArcGIS community, though there's probably at least some GDAL users. And please next time post text as text not screenshots (you can use the code formatting button in the advanced editor). Text is hard to read in an image.