问题描述
我正在 Jupyter Notebook 中制作一个脚本,它将在循环中执行多个 ogr2ogr
转换。据我所知,我不能直接将变量传递给 ogr2ogr。我可以用字符串格式化程序来做到这一点吗?
! ogr2ogr -f "ESRI Shapefile" {fout} "my_orignal_shp.shp".format(fout = "my_output.shp")
返回
FAILURE: Unable to open datasource `my_output.shp.format(fout' with the following drivers.
和 ! (ogr2ogr -f "ESRI Shapefile" {fout} "my_orignal_shp.shp").format(fout = "my_output.shp")
返回 .format(fout was unexpected at this time.
使用 Windows、Python 3.7、GDAL 3.3.1 和 Jupyter Notebook
更新 我还尝试了以下内容,如 GDAL Examples Guide
command = 'ogr2ogr -f "ESRI Shapefile" {i} {o}'
i = r'D:\Documents\my_orignal_shp.shp'
o = r'D:\Documents\my_output.shp'
! os.system(command.format(input=fin,output=fout))
并收到此错误:'os.system' is not recognized as an internal or external command,operable program or batch file.
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)