Diskussion:Workshop QGIS Python GeoPython 2017: Unterschied zwischen den Versionen
Aus Geoinformation HSR
Simran (Diskussion | Beiträge) |
Stefan (Diskussion | Beiträge) K |
||
Zeile 4: | Zeile 4: | ||
* https://etherpad.coredump.ch/p/Python-Workshop | * https://etherpad.coredump.ch/p/Python-Workshop | ||
− | User Defined or ''Custom Expression Functions ( | + | User Defined or ''Custom Expression Functions (custom EFs)'' can be used in ... |
# "Layer > Properties > Tab Fields" in Button "Text Edit" in Default- and in Constraints-Field. | # "Layer > Properties > Tab Fields" in Button "Text Edit" in Default- and in Constraints-Field. | ||
# "Layer > Properties > Tab Style" in "Label with". | # "Layer > Properties > Tab Style" in "Label with". | ||
Zeile 10: | Zeile 10: | ||
# "Field Calculator". | # "Field Calculator". | ||
# "Statistical Summary" Panel. | # "Statistical Summary" Panel. | ||
− | # "Map Tip" tool | + | # "Map Tip" tool. |
− | # "Conditional formatting" in the attribute table (Create a new rule and set the condition to the output of a | + | # "Conditional formatting" in the attribute table (Create a new rule and set the condition to the output of a custom EF). |
# "Filtering features". Switch to the form view in the attribute table (button on bottom right corner) > click on 'Show All Features' (bottom left) and select 'Advanced Filter (Expression)'. | # "Filtering features". Switch to the form view in the attribute table (button on bottom right corner) > click on 'Show All Features' (bottom left) and select 'Advanced Filter (Expression)'. | ||
# "Atlas Generation" in the Print Composer. Project > Print Composer > Check 'generate an atlas' > Set CEF based values for page name, filter and output filename. | # "Atlas Generation" in the Print Composer. Project > Print Composer > Check 'generate an atlas' > Set CEF based values for page name, filter and output filename. | ||
# "Rule based labeling". Layer Properties > Labels > Select Rule based labeling from the drop-down menu > Click on the '+' button and add a CEF based filter (... button). | # "Rule based labeling". Layer Properties > Labels > Select Rule based labeling from the drop-down menu > Click on the '+' button and add a CEF based filter (... button). | ||
− | # (other places | + | # Part of "Geometry generator" in "Style > Symbol Layer Type" |
+ | # ''(add other places here)'' | ||
Version vom 7. Mai 2017, 00:39 Uhr
See also
- Step-by-step guide for the workshop on Github.
- https://github.com/simran001/PyQGIS
- https://etherpad.coredump.ch/p/Python-Workshop
User Defined or Custom Expression Functions (custom EFs) can be used in ...
- "Layer > Properties > Tab Fields" in Button "Text Edit" in Default- and in Constraints-Field.
- "Layer > Properties > Tab Style" in "Label with".
- "Select features using an expression".
- "Field Calculator".
- "Statistical Summary" Panel.
- "Map Tip" tool.
- "Conditional formatting" in the attribute table (Create a new rule and set the condition to the output of a custom EF).
- "Filtering features". Switch to the form view in the attribute table (button on bottom right corner) > click on 'Show All Features' (bottom left) and select 'Advanced Filter (Expression)'.
- "Atlas Generation" in the Print Composer. Project > Print Composer > Check 'generate an atlas' > Set CEF based values for page name, filter and output filename.
- "Rule based labeling". Layer Properties > Labels > Select Rule based labeling from the drop-down menu > Click on the '+' button and add a CEF based filter (... button).
- Part of "Geometry generator" in "Style > Symbol Layer Type"
- (add other places here)
Possible examples
- Function doing something "local" like from other field(s).
- Functions reading something like a "Singleton" like a system environment variable (usage "env('USERNAME')") layer properties or number sequence (spcial Plugin needed?).
- Function for remote webservice: geocoding (reading from the internet).
- Out of scope: Function reading from other layers (rather candidate for a plugin).
After the GeoPython Workshop, Simran makes pull request to Expression Plus Plugin adding "env()" fn.
Optional (but highly demanded) use case: A user wants to create a layer (table) which as a primary key (id) which behaves like 'autoincrement' when user edit a new feature. So user does not have to care about unique, sequential values for the PK, like autoincrement in MySQL). In QGIS 3 this is available when user chooses "UNIQUE" as constraint. In QGIS 2.18 (or before) there is a clever custom expression function needed. => Solution?
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: http://plugins.qgis.org/plugins/refFunctions/
- spatialJoin (depends on refFunctions): http://plugins.qgis.org/plugins/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