zoukankan      html  css  js  c++  java
  • 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()

     

  • 相关阅读:
    Android——活动的基本用法
    开课第五周周总结
    java常用框架
    javaweb学习
    每日日报2021.3.23
    每日日报2021.3.22
    每日日报2021.3.21
    每日日报2021.3.19
    每日日报2021.3.18
    每日日报2021.3.17
  • 原文地址:https://www.cnblogs.com/icoolno1/p/7231867.html
Copyright © 2011-2022 走看看