Diskussion:Workshop QGIS Python GeoPython 2017: Unterschied zwischen den Versionen
Aus Geoinformation HSR
Stefan (Diskussion | Beiträge) K |
Stefan (Diskussion | Beiträge) K |
||
Zeile 6: | Zeile 6: | ||
Background - Where are Expression Functions used? | Background - Where are Expression Functions used? | ||
− | * Any place | + | * 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 | ||
− | + | * See http://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/expression.html?highlight=expression | |
− | |||
− | |||
− | |||
Possible examples: | Possible examples: | ||
# Function reading from other feature properties | # Function reading from other feature properties | ||
− | # Functions aka predefined variables (@), "Singletons" like | + | # Functions aka predefined variables ("@layer_name"), "Singletons" like system environment variables (usage "env('USERNAME')") layer properties or number sequence (spcial Plugin needed?) |
# Function for remote webservice: geocoding (reading from the internet) | # Function for remote webservice: geocoding (reading from the internet) | ||
# Function reading from other layers (1:1) | # Function reading from other layers (1:1) | ||
+ | === Writing === | ||
+ | |||
+ | 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: | ||
+ | * Autoincrement / Sequence => QGIS 2.18 default Werte (QGIS 3 geplant) | ||
+ | * Given polygon layer and a point one, calculate for each polygon feature, the number of points that it covers: https://lists.osgeo.org/pipermail/qgis-user/2016-October/038139.html http://gis.stackexchange.com/questions/212415/referencing-to-features-geometry-in-an-expression/212762#212762 | ||
+ | * Add attributes from a layer in the project or an external file (csv) to a layer (or the composer?) using insert expression? Create a custom expression python function to do this: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/ | ||
Plugins: | Plugins: | ||
− | * ExpressionPlus (for QGIS) | + | * ExpressionPlus (for QGIS) Extra functions for the expression engine which didn't make it into QGIS 2.0: https://plugins.qgis.org/plugins/qgsexpressionsplus/ |
* refFunctions | * refFunctions | ||
* spatialJoin | * spatialJoin | ||
− | * AutoFields (obsolete) | + | * AutoFields (obsolete) - Automatic Field Calculator Plugin: http://plugins.qgis.org/plugins/AutoFields/ |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | Open: | |
− | + | * How to store a value in PyQGIS? Use QSettings (/.qgis) or QGISProject (.qgs) | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | Resource Sharing Plugin (http://plugins.qgis.org/plugins/qgis_resource_sharing/) | + | * Resource Sharing Plugin (http://plugins.qgis.org/plugins/qgis_resource_sharing/). e.g. https://github.com/mara91/qgis_styles.git |
− |
Version vom 9. März 2017, 15:17 Uhr
See also
Custom Python Expression Functions for QGIS
Background - 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.
- Processing => Refactor fields
- See http://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/expression.html?highlight=expression
Possible examples:
- Function reading from other feature properties
- Functions aka predefined variables ("@layer_name"), "Singletons" like system environment variables (usage "env('USERNAME')") layer properties or number sequence (spcial Plugin needed?)
- Function for remote webservice: geocoding (reading from the internet)
- Function reading from other layers (1:1)
Writing
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:
- Autoincrement / Sequence => QGIS 2.18 default Werte (QGIS 3 geplant)
- Given polygon layer and a point one, calculate for each polygon feature, the number of points that it covers: https://lists.osgeo.org/pipermail/qgis-user/2016-October/038139.html http://gis.stackexchange.com/questions/212415/referencing-to-features-geometry-in-an-expression/212762#212762
- Add attributes from a layer in the project or an external file (csv) to a layer (or the composer?) using insert expression? Create a custom expression python function to do this: http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/
Plugins:
- ExpressionPlus (for QGIS) Extra functions for the expression engine which didn't make it into QGIS 2.0: https://plugins.qgis.org/plugins/qgsexpressionsplus/
- refFunctions
- spatialJoin
- AutoFields (obsolete) - Automatic Field Calculator Plugin: http://plugins.qgis.org/plugins/AutoFields/
Open:
- How to store a value in PyQGIS? Use QSettings (/.qgis) or QGISProject (.qgs)
- Resource Sharing Plugin (http://plugins.qgis.org/plugins/qgis_resource_sharing/). e.g. https://github.com/mara91/qgis_styles.git