在python中调用grass的模块
来源:互联网 发布:关于网络直播的作文800 编辑:程序博客网 时间:2024/05/22 17:37
在安装好grass之后,只需设置如下的环境变量,便可在python中调用grass中的模块功能:
GISBASE= D:\Program Files (x86)\GRASS GIS 7.0.svnPATH=%GISBASE%\etc;%GISBASE%\etc\python;%GISBASE%\lib;%GISBASE%\bin;%GISBASE%\extrabin;C:\Python27\ArcGIS10.1;%GISBASE%\scripts;%GISBASE%\msys\bin;%GISBASE%\Python27\libLD_LIBRARY_PATH= %GISBASE%\libPYTHONPATH= %GISBASE%\etc\pythonPYTHONLIB= C:\Python27\ArcGIS10.1GRASS_SH= %GISBASE%\msys\bin\sh.exe
示例Python程序如下:
import sysimport osimport grass.script as grasskk = r"E:\Exercise\test\grasstest\dem2.tif"r = grass.run_command('r.in.gdal', flags='o', input=kk, output="mm", overwrite=True)print rr = grass.run_command("g.region", rast="mm")print r
但是我们需要注意的几个问题:
- 目前grass官网上能下载的最新版本的wingrass(Stand-alone Installer) 版本为7.0.4,https://grass.osgeo.org/download/software/ms-windows/,但是安装之后安装目录下没有文件夹msys,因此环境变量中凡是与msys有关的无法进行设置。本文的解决办法是下载一个旧版本的grass即可,我用的是WinGRASS-7.0.svn版。
- 有时候在安装旧版本的grass(指的是7.0.3之前的版本)后,启动时会报错。如下图:
第一幅图是启动grass时报错 unable to get current geographic extent. Force quiting wxGUI.,然后根据提示在grass的cmd中运行命令g.region,又报错:g.region.exe无法找到入口,无法定位程序输入点sqlite3_prepare_v2于动态链接库sqlite3.dll上。此时的解决办法是
The issue is caused by different sqlite3.dll files accessible “on path” to all application. In case of GRASS GIS, some incompatible sqlite3 DLL is picked up by the system rather than using the correct one shipped with GRASS GIS.
Solution: search for all sqlite3.dll files on your computer and remove rename them one by one while trying at the same time to start GRASS GIS successfully. Note that removing some of the other sqlite3.dll files may break the applications which use them (say, while this is possible it has never actually been reported by any user). So, it is a good idea to just rename the DLL file in case you discover that another application needs that particular sqlite3 DLL and you have to reverse the process.
- 在python中调用grass的模块
- 在Meteor中调用NodeJS模块或者自己的模块
- Python 3.X 调用多线程C模块,并在C模块中回调python函数的示例
- Python 3.X 调用多线程C模块,并在C模块中回调python函数的示例
- Python media 模块的调用
- python的模块代码调用
- Python接口(2):使用ctpyes模块在python中调用c++代码
- 在linux中 应用程序如何调用模块内的函数
- 在linux中 应用程序如何调用模块内的函数
- 在linux中应用程序如何调用模块内的函数
- 在linux中 应用程序如何调用模块内的函数
- 在linux中应用程序如何调用模块内的函数
- [Python]在Python中添加自定义模块
- Windows 下在 Python 中安装 Swampy 模块的方法
- 在Win7中使用Python的MySQLdb模块
- 在handelc中直接调用verilog模块
- 在python 中调用Dll
- 在Java中调用Python
- 新浪微博手机端很难成为一个常用APP
- 超线程、多核知识实战,5分钟让你成为CPU专家
- url传递中文字符,特殊危险字符的解决方案
- 【grunt整合版】30分钟学会使用grunt打包前端代码
- PHP 10问——PART 3
- 在python中调用grass的模块
- IIS6.0 应用程序池Web园导致Session丢失(转改添加)
- 在Hyper-V环境下进行安装Centos7系统
- html5+js拖拽上传的那些事
- Android应用性能优化系列视图篇——恼人的分割线留白解决之道
- 关于我自己的
- HTML基础样式(三)
- android studio的配置版本号和名称
- java 实现WebService 以及不同的调用方式