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

Aus Geoinformation HSR
Wechseln zu: Navigation, Suche
K
K
Zeile 5: Zeile 5:
 
''Custom Python Expression Functions for QGIS''
 
''Custom Python Expression Functions for QGIS''
  
Background - Where are Expression Functions used?
+
 
 +
=== Using Expression Functions ====
 +
 
 +
Where are Expression Functions used?
 
* Any place where expressions are allowed, e.g. in Attribute Table as Select-Filter, in Field Calculator when creating/updatin fields.
 
* Any place where expressions are allowed, e.g. in Attribute Table as Select-Filter, in Field Calculator when creating/updatin fields.
 
* Processing => Refactor fields
 
* Processing => Refactor fields
Zeile 16: Zeile 19:
 
# Function reading from other layers (1:1)
 
# Function reading from other layers (1:1)
  
=== Writing ===
+
 
 +
=== Writing Expression Functions ===
  
 
How to install and share an Expression Function?
 
How to install and share an Expression Function?

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

See also

Custom Python Expression Functions for QGIS


Using Expression Functions =

Where are Expression Functions used?

Possible examples:

  1. Function reading from other feature properties
  2. Functions aka predefined variables ("@layer_name"), "Singletons" like system environment variables (usage "env('USERNAME')") layer properties or number sequence (spcial Plugin needed?)
  3. Function for remote webservice: geocoding (reading from the internet)
  4. Function reading from other layers (1:1)


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 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)