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