Diskussion:Workshop QGIS Python GeoPython 2017: Unterschied zwischen den Versionen

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
K (Using Expression Functions)
K (Writing Expression Functions)
Zeile 27: Zeile 27:
 
How to install and share an Expression Function?
 
How to install and share an Expression Function?
 
* Save and (Re-)Load in "Function Edtior" (saves to "%USERHOME%.qgis2\python\expressions" (where %USERHOME% under Windows is e.g. "C:\Users\sfkeller\").
 
* Save and (Re-)Load in "Function Edtior" (saves to "%USERHOME%.qgis2\python\expressions" (where %USERHOME% under Windows is e.g. "C:\Users\sfkeller\").
* Add Fn. to qgis2/python/startup.py
+
* Add Fn. to "%USERHOME%.qgis2\python\startup.py ()
 
* Add Fn. to the "Expresion Plus Plugin"  
 
* Add Fn. to the "Expresion Plus Plugin"  
 
* Add Fn. to any (own and loaded) QGIS plugin
 
* Add Fn. to any (own and loaded) QGIS plugin
Zeile 34: Zeile 34:
 
* use "print"
 
* use "print"
 
* use pdb (see QGIS docs and giswiki)
 
* use pdb (see QGIS docs and giswiki)
* (use Remote Debug Plugin)  
+
* (use Remote Debug Plugin)
 
 
  
 
== Notes ==
 
== Notes ==

Version vom 9. März 2017, 15:29 Uhr

See also

Custom Python Expression Functions for QGIS


Using Expression Functions

Where are Expression Functions used?

  • Any place where expressions are allowed, e.g. in Attribute Table as Select-Filter, Label-Properties, in Field Calculator when creating/updating fields.
  • Processing => Refactor fields

How to use:

Possible examples:

  1. Function doing something "local".
  2. Function reading from other field(s).
  3. Functions aka "Singleton" like system environment variables (usage "env('USERNAME')") layer properties or number sequence (spcial Plugin needed?).
  4. Function for remote webservice: geocoding (reading from the internet).
  5. Function reading from other layers (outlook, rather candidate for a plugin).

Writing Expression Functions

How to install and share an Expression Function?

  • Save and (Re-)Load in "Function Edtior" (saves to "%USERHOME%.qgis2\python\expressions" (where %USERHOME% under Windows is e.g. "C:\Users\sfkeller\").
  • Add Fn. to "%USERHOME%.qgis2\python\startup.py ()
  • Add Fn. to the "Expresion Plus Plugin"
  • Add Fn. to any (own and loaded) QGIS plugin

Debugging:

  • use "print"
  • use pdb (see QGIS docs and giswiki)
  • (use Remote Debug Plugin)

Notes

Collected (special) use cases:

Plugins:

Open:

  • How to store a value in PyQGIS? Use QSettings (/.qgis) or QGISProject (.qgs)