【发布时间】:2016-10-26 13:48:43
【问题描述】:
我在将图像文件写入 PC 上的文件夹时遇到了一些问题。 正如您在下面的脚本中看到的那样,我使用了 os.path.expanduser,因为我打算使用将此脚本发送到另一台计算机,该计算机显然与我的本地 PC 没有相同的文件路径。当我运行这个脚本时,gdal_calc 运行正常,但是,没有输出?任何关于如何创建输出文件或可能导致图像消失的想法将不胜感激。
#!/usr/bin/env bash
import subprocess
from subprocess import call
import sys
import os
# Set constants
# The pathway to the image files are nested within the '--outfile=' command
inHVFile = os.path.expanduser('~\\Desktop\\Zeros\\ZerosHV-Test-3.img')
outPlacement = os.path.expanduser('~\\Desktop\\newHVZeros.img')
outVFile = '--outfile=outPlacement'
outVFile_1 = '--outfile=outPlacement_1'
inVHFile = os.path.expanduser('~\\Desktop\\Zeros\\ZerosVH-Test-3.img')
outPlacement_1 = os.path.expanduser('~\\Desktop\\newVHZeros.img')
subprocess.call([sys.executable, 'C:\\Program Files (x86)\\GDAL\\gdal_calc.py','-A', inHVFile, outVFile, '--calc=A+1'])
subprocess.call([sys.executable, 'C:\\Program Files (x86)\\GDAL\\gdal_calc.py','-A', inVHFile, outVFile_1, '--calc=A+1'])
【问题讨论】:
标签: python-3.x operating-system gdal