问题描述
我必须在子进程中从python运行gdal命令。 我尝试的第一个命令是gdalsrsinfo。
self.proc = subprocess.Popen(['gdalsrsinfo','-e','D:\tif\dop20c_33328_5650.tif'],stdout=subprocess.PIPE,stderr=subprocess.STDOUT,shell=True)
while self.proc.poll() is None:
output = self.proc.stdout.readline().strip()
self.print_log.emit(output)
if output.startswith(b'epsg:'):
epsg = output.rsplit(':',1)[1]
self.print_log.emit(output)
进入while循环后,该过程开始。但是输出变量始终为空。当我在shell中执行相同的命令时,我得到正确的输出。 我如何从python的shell中获得相同的输出?我还将尝试其他gdal命令并获得结果。我没有任何输出。
我正在使用python 3.7的Windows 10
顺便说一句,我的shell中命令的输出如下:
A:\>gdalsrsinfo -e D:\tif\dop20c_33328_5650.tif
epsg:25833
PROJ.4 : +proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0 +units=m +no_defs
OGC WKT2:2018 :
PROJCRS["ETRS89 / UTM zone 33N",BASEGEOGCRS["ETRS89",DATUM["European Terrestrial Reference System 1989",ELLIPSOID["GRS 1980",6378137,298.257222101,LENGTHUNIT["metre",1]]],PRIMEM["Greenwich",ANGLEUNIT["degree",0.0174532925199433]],ID["epsg",4258]],CONVERSION["UTM zone 33N",METHOD["Transverse Mercator",9807]],ParaMETER["Latitude of natural origin",0.0174532925199433],8801]],ParaMETER["Longitude of natural origin",15,8802]],ParaMETER["Scale factor at natural origin",0.9996,SCALEUNIT["unity",1],8805]],ParaMETER["False easting",500000,8806]],ParaMETER["False northing",8807]]],CS[Cartesian,2],AXIS["(E)",east,ORDER[1],1]],AXIS["(N)",north,ORDER[2],USAGE[
ScopE["unkNown"],AREA["Europe - 12°E to 18°E and ETRS89 by country"],BBox[46.4,12,84.01,18.01]],25833]]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)