Qgis 里的Python脚本介绍

QGIS 入门演示之《用 QGIS 画矢量交通路线图

脚本编程之准备知识《Python 教程

QGIS API

QGIS插件库

运行QGIS脚本,对于桌面应用来讲有4种方式:

  • QGIS 启动时自动运行Python脚本
  • QGIS 控制台中运行发布的Python命令
  • 创建Python写的插件
  • 创建基于QGIS API的应用程序

QGIS服务端绑定:

  • 2.8 开始,QGIS服务端包含Python插件 (see: Server Python Plugins)
  • 2.11开始 (2015-08-11), QGIS 服务库包含Python 绑定,可以在Python应用中嵌入QGIS服务。

1、 启动脚本

启动脚本可以通过指定环境变量PYQGIS_STARTUP来指定启动时运行的脚本。也可以编辑位于安装目录.qgis2/python/startup.py 文件。

2、控制台

通过菜单:Plugins ‣ Python Console 来打开。

3、插件

如何创建插件

4、应用程序

1) 独立脚本

使用PyQGIS 来创建脚本

from qgis.core import *

# supply path to qgis install location
QgsApplication.setPrefixPath("/path/to/qgis/installation", True)

# create a reference to the QgsApplication, setting the
# second argument to False disables the GUI
qgs = QgsApplication([], False)

# load providers
qgs.initQgis()

# Write your code here to load some layers, use processing algorithms, etc.

# When your s

 

2)自定义程序

from qgis.core import *

# supply path to qgis install location
QgsApplication.setPrefixPath("/path/to/qgis/installation", True) # create a reference to the QgsApplication # setting the second argument to True enables the GUI, which we need to do # since this is a custom application qgs = QgsApplication([], True) # load providers qgs.initQgis() # Write your code here to load some layers, use processing algorithms, etc. # When your script is complete, call exitQgis() to remove the provider and # layer registries from memory qgs.exitQgis()

 

 

转载于:https://www.cnblogs.com/icoolno1/p/7231867.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值