Introduction to the Python script in Qgis

Source: Internet
Author: User
Tags python script

QGIS Introductory presentation of "Vector traffic route map with QGIS" Preparation of script programming Knowledge Python Tutorial QGIS Apiqgis Plugin Library

There are 4 ways to run Qgis scripts for desktop applications:

    • QGIS automatically run Python scripts at startup
    • Run a published Python command in the QGIS console
    • Create a python-written plugin
    • Creating an application based on the Qgis API

Qgis Service-side bindings:

    • 2.8 Start, Qgis server contains python plugin (see:server python Plugins)
    • 2.11 Start (2015-08-11), the QGIS service library contains Python bindings that can embed QGIS services in Python apps.
1. Startup script

The startup script can specify the script to run at startup by specifying the environment variable PYQGIS_STARTUP. You can also edit the. qgis2/python/startup.py file that is located in the installation directory.

2. Control Station

Via menu: Plugins? Python Console to open.

3. Plugins

"How to create a plugin"

4. Application 1) stand-alone script

Use Pyqgis to create a script

 fromQgis.coreImport*#Supply path to Qgis install locationQgsapplication.setprefixpath ("/path/to/qgis/installation", True)#Create a reference to the Qgsapplication, setting the#second argument to False disables the GUIQgs =qgsapplication ([], False)#Load ProvidersQgs.initqgis ()#Write Your code here to load some layers, use processing algorithms, etc.#When your s

2) Custom Programs
FromQgis.coreImport*# Supply path to Qgis install locationQgsapplication.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 does# since this is a custom applicationqgs = qgsapplication([], True)  # Load ProvidersQgs.  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 memoryQgs.  Exitqgis()                 

Introduction to the Python script in Qgis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.