简体   繁体   English

结合QGIS在MAC终端中使用GDAL和ogr实用程序

[英]Using GDAL and ogr utilities in MAC terminal in conjunction with QGIS

I am pretty new to the open-source GIS software. 我是开源GIS软件的新手。 I am trying to clip and project data layers using GDAL and ogr in my MAC terminal. 我试图在我的MAC终端中使用GDAL和ogr裁剪和投影数据层。 I can get the data to clip when I am just clipping but when I try and combine the two (clip and project), I am getting a syntax error. 当我只是剪切时,我可以剪切数据,但是当我尝试将两者(剪切和项目)结合在一起时,出现语法错误。 The syntax I have was written for Command Line and I'm thinking I may need to tweak it for terminal. 我为命令行编写的语法,我认为可能需要对终端进行调整。 Any help would be greatly appreciated! 任何帮助将不胜感激! If someone is willing to help, I will try and provide more information if necessary. 如果有人愿意提供帮助,我将在必要时尝试提供更多信息。

Here is my line of code: 这是我的代码行:

$for %X in (*.shp) do ogr2ogr -skipfailures -clipsrc
~/Desktop/PhiladelphiaBaseLayers/clipFeature/city_limits.shp
~/Desktop/PhiladelphiaBaseLayers/clipped/%X
~/Desktop/PhiladelphiaBaseLayers/%X

When I run the code, I receive this error message: 当我运行代码时,我收到以下错误消息:

-bash: syntax error near unexpected token `('

Switcher from windows to mac? 从Windows切换到Mac? ;) ;)

If I understand right your intent is run the ogr2ogr with 3 file arguments 如果我理解正确,您的意图是使用3个文件参数运行ogr2ogr

try the next 尝试下一个

for shpfile in *.shp
do
    echo ogr2ogr -skipfailures -clipsrc \
       ~/Desktop/PhiladelphiaBaseLayers/clipFeature/city_limits.shp \
       ~/Desktop/PhiladelphiaBaseLayers/clipped/"$shpfile" \
       ~/Desktop/PhiladelphiaBaseLayers/"$shpfile"
done

when you satisfied, remove the echo 当您满意时,删除echo

This is what ultimately worked for me. 这才是最终为我工作的东西。 Take out the quotations around the variable call. 删除变量调用周围的引号。 All one line. 全部一行。

for f in *.shp; 对于* .shp中的f; do ogr2ogr -skipfailures -clipsrc ~/documents/PhiladelphiaBaseLayers/clipFeature/city_limits.shp ~/documents/PhiladelphiaBaseLayers/clipped/$f ~/documents/PhiladelphiaBaseLayers/$f; 做ogr2ogr -skipfailures -clipsrc〜/ documents / PhiladelphiaBaseLayers / clipFeature / city_limits.shp〜/ documents / PhiladelphiaBaseLayers / clipped / $ f〜/ documents / PhiladelphiaBaseLayers / $ f; done DONE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM