InVEST模型 | 02 InVEST模型Python安装

InVEST在生态系统评估领域有着广泛的应用,由于其交互界面简洁直接,大大降低了模型的使用门槛。但当需要多次、多区域的运算时,手动点击的方法十分耗时费力,针对这样的情况,InVEST团队推出了natcap.invest接口,使用Python脚本直接调用相关的生态系统评估模块,可以显著提升工作效率。本文是针对natcap.invest在windows10上安装过程的记录。

  • 1. 首先,安装Python3.6以上版本

通过Anaconda新建一个Python版本为3.6的虚拟环境,在CMD窗口中输入:

conda create -n pyinvest python=3.6
conda activate pyinvest
  • ** 2. 安装InVEST相关的依赖库**

安装时要注意InVEST对于依赖库版本的要求:(一般推荐使用conda安装,conda对包的管理比pip严格)

GDAL>=2.0,❤️.0
Pyro4==4.77 # pip-only
pandas>=1.0
numpy>=1.11.0,!=1.16.0
Rtree>=0.8.2,!=0.9.1
scipy>=0.16.1,<1.5.0
Shapely>=1.6.4,<1.7.0
pygeoprocessing>=1.9.2,<2.0 # pip-only
taskgraph[niced_processes]==0.9.1
psutil>=5.6.6
chardet>=3.0.4
xlrd>=1.2.0
xlwt

例如gdal的安装,就需要指定版本,不然conda会默认安装上最新的>3.0版本的gdal

conda install gdal=2.4.1 -c conda-forge

同理,对于使用pip安装的依赖,如Pyro4安装,也需要指定相应的版本

pip install pyro4=4.77
  • ** 3. 安装InVEST的Python包**

此处主要有两种方法:

(1) 直接下载预编译包进行安装:(推荐)

下载地址为:Releases on the python package index

本文用到的.whl文件为 natcap.invest-3.8.9-cp36-cp36m-win_amd64.whl

下载完成,找到文件所在的目录,输入:

pip install natcap.invest-3.8.9-cp36-cp36m-win_amd64.whl

(2) 下载源码编译后再安装:

要注意使用这种方式安装之前需要本机上有c/c++的编译器

pip install “git+https://github.com/natcap/invest@master#egg=natcap.invest”

至此,natcap.invest已经安装完成,可以打开Python进行测试是否安装成功

python

import natcap.invest.habitat_quality

如果导入包不出错,则证明安装成功

  • ** 4. 安装InVEST的UI界面**

为了方便使用,还可以安装InVEST的UI界面,基于pyqt,在命令行中输入:

pip install natcap.invest[ui]

安装完成后,运行:

invest run carbon

即可看到carbon模块的可视化界面

至此,natcap.invest全部安装成功

参考链接:

安装教程相关:

https://invest.readthedocs.io/en/latest/scripting.html

https://pypi.org/project/natcap.invest/#files

https://pypi.org/project/natcap.invest/3.8.9/

安装过程中出现的BUG:

error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ Tools":

解决:https://zhuanlan.zhihu.com/p/126669852

jupyter中添加新环境:

解决:https://www.cnblogs.com/hgl0417/p/8204221.html

运行产水量模块时报错:

WARNING [errno 6] driver GTiff does not support creation option BIGTIFF
BigTIFF requested, but GDAL built without BigTIFF enabled libtiff, request ignored.

原因是gdal=2.3.2版本中没有含有libtiff模块,解决方法是安装gdal=2.4.1版本

解决链接:https://github.com/ContinuumIO/anaconda-issues/issues/9887

在安装pygeoprocessing时,pip报错:

ERROR: Failed building wheel for GDAL
Failed to build GDAL

Then it has a DEPRECATION comment about not being able to build wheels for GDAL which do not use PEP 517. And pip will fall back to legacy ‘setup.py install’ for these.

解决链接:https://community.naturalcapitalproject.org/t/unable-to-install-pygeoprocessing-on-mac/1276/4

https://pygeoprocessing.readthedocs.io/en/latest/installing.html

https://blog.csdn.net/weixin_40547993/article/details/89399825

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-CMARZROT-1676603934098)(null)]

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值