Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: MZPCS on November 15, 2013, 01:09:28 AM

Title: Run GDAL in Agisoft Python script
Post by: MZPCS on November 15, 2013, 01:09:28 AM
Hello,

I've written Python code that successfully automates an Agisoft workflow and runs in Agisoft and would like to add a step at the end using gdal_merge after Agisoft exports a blocked orthophoto.  Any tips on how to get GDAL functional from a script running within Agisoft?  Currently I can run gdal_merge from other places like OSGeo4W shell or a windows batch file that I created.  But it would be less steps for users to tack the merge at the end of the script in Agisoft.  Maybe this question is more about how to successfully install GDAL into Agisoft's Python environment.  Has anyone accomplished this?

Thanks!
Kevin
Title: Re: Run GDAL in Agisoft Python script
Post by: jedfrechette on November 15, 2013, 11:48:58 PM
You should be able to use Python's built-in subprocess module [1] to call gdal_merge as if you were running it from a standalone command line. I haven't tried it but I suspect you could also install GDAL's Python bindings within PhotoScans private Python installation so that you could use its API directly.

[1] http://docs.python.org/3.3/library/subprocess.html