[QGIS-Developer] Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[QGIS-Developer] Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Stefan Keller
Hi,

Tomorrow I'll be giving a Workshop about "Easy Programming QGIS with
Python for custom Expression Functions (EFns)" [1].

Question 1: Below you'll find an initial list I compiled where EFns
are used in QGIS Desktop. => Did I miss an occurrence?

Question 2: I tried to make a categorization for several reasons. One
reason for this is to realize that a EFn may not work outside QGIS
Desktop. Style-related EFns for example won't work currently in
qgis2web or QGISCloud. => Any comments?

:Stefan

[1] https://2017.geopython.net/#schedule

List where EFns are used in QGIS (probably incomplete):

"Server-side" / data-related:
* "Select features using an expression" (Layer property).
* "Filtering features" while loading from source. 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)'.
* "Layer > Properties > Tab Fields" in Button "Text Edit" in Default-
and in Constraints-Field.
* "Layer > Properties > Tab Style" in "Label with".
* "Field Calculator" to defining new or virtual fields (Layer property).
* "Conditional formatting" in the attribute table (Create a new rule
and set the condition to the output of a custom EFn).
Analysis-related:
* "Statistical Summary" Panel (Layer property).
* "Atlas Generation" in the Print Composer. Project > Print Composer >
Check 'generate an atlas' > Set CEF based values for page name, filter
and output filename.
"Client-side" / style-related:
* "Map Tip" tool (Layer property).
* "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"
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

DelazJ
Hi,
I may have overlooked your list but note that anytime you find a data-defined override button, there's an expression dialog behind (using the Edit option), and this button is spread over layer properties dialog (style, diagram, label...) and composer items' options (almost all). Processing algorithms also have the expression engine.

Some update of the official docs (though we didn't go through each dialog) https://docs.qgis.org/2.18/en/docs/user_manual/working_with_vector/expression.html

Harrissou

2017-05-07 17:01 GMT+02:00 Stefan Keller <[hidden email]>:
Hi,

Tomorrow I'll be giving a Workshop about "Easy Programming QGIS with
Python for custom Expression Functions (EFns)" [1].

Question 1: Below you'll find an initial list I compiled where EFns
are used in QGIS Desktop. => Did I miss an occurrence?

Question 2: I tried to make a categorization for several reasons. One
reason for this is to realize that a EFn may not work outside QGIS
Desktop. Style-related EFns for example won't work currently in
qgis2web or QGISCloud. => Any comments?

:Stefan

[1] https://2017.geopython.net/#schedule

List where EFns are used in QGIS (probably incomplete):

"Server-side" / data-related:
* "Select features using an expression" (Layer property).
* "Filtering features" while loading from source. 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)'.
* "Layer > Properties > Tab Fields" in Button "Text Edit" in Default-
and in Constraints-Field.
* "Layer > Properties > Tab Style" in "Label with".
* "Field Calculator" to defining new or virtual fields (Layer property).
* "Conditional formatting" in the attribute table (Create a new rule
and set the condition to the output of a custom EFn).
Analysis-related:
* "Statistical Summary" Panel (Layer property).
* "Atlas Generation" in the Print Composer. Project > Print Composer >
Check 'generate an atlas' > Set CEF based values for page name, filter
and output filename.
"Client-side" / style-related:
* "Map Tip" tool (Layer property).
* "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"
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Andreas Neumann-4
In reply to this post by Stefan Keller
Hi Stefan,

Expressions also work in QGIS cloud (which is QGIS server based) - but
Python based expressions don't work in QGIS server.

I have to say, however, that the QGIS core expressions are already quite
powerful and I don't often have the need to create my own custom Python
based expressions. I just recently had to use them - but that is the
fist time after many years ;-)

What is your reason that you have to use Python based expression as
opposed to the core built-in expressions?

Andreas


On 07.05.2017 17:01, Stefan Keller wrote:

> Hi,
>
> Tomorrow I'll be giving a Workshop about "Easy Programming QGIS with
> Python for custom Expression Functions (EFns)" [1].
>
> Question 1: Below you'll find an initial list I compiled where EFns
> are used in QGIS Desktop. => Did I miss an occurrence?
>
> Question 2: I tried to make a categorization for several reasons. One
> reason for this is to realize that a EFn may not work outside QGIS
> Desktop. Style-related EFns for example won't work currently in
> qgis2web or QGISCloud. => Any comments?
>
> :Stefan
>
> [1] https://2017.geopython.net/#schedule
>
> List where EFns are used in QGIS (probably incomplete):
>
> "Server-side" / data-related:
> * "Select features using an expression" (Layer property).
> * "Filtering features" while loading from source. 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)'.
> * "Layer > Properties > Tab Fields" in Button "Text Edit" in Default-
> and in Constraints-Field.
> * "Layer > Properties > Tab Style" in "Label with".
> * "Field Calculator" to defining new or virtual fields (Layer property).
> * "Conditional formatting" in the attribute table (Create a new rule
> and set the condition to the output of a custom EFn).
> Analysis-related:
> * "Statistical Summary" Panel (Layer property).
> * "Atlas Generation" in the Print Composer. Project > Print Composer >
> Check 'generate an atlas' > Set CEF based values for page name, filter
> and output filename.
> "Client-side" / style-related:
> * "Map Tip" tool (Layer property).
> * "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"
> _______________________________________________
> QGIS-Developer mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Stefan Keller
Good question! According to the workshop registrations quite some
other attendees seem to be interested too at least to know more about
this :-)

In the workshop we demonstrate custom Expression Functions (EFns) from
Nathan's plugin https://github.com/NathanW2/qgsexpressionsplus which
contains some useful functions missing in core like max_incremented()
aka auto-increment, hstore_get_key for fields with key-value pairs,
etc. Then we show get_address() in order to reverse geocode lat/lon to
an address,

Then think for example about a custom EFn (not yet implemented):
* env() which returns system environment variables;
* nullif() which turns empty strings to NULL (with build-in condition);
* which generates a fuzzy or scribbled boundary on the fly.
* etc.

:Stefan

2017-05-07 21:51 GMT+02:00 Andreas Neumann <[hidden email]>:

> Hi Stefan,
>
> Expressions also work in QGIS cloud (which is QGIS server based) - but
> Python based expressions don't work in QGIS server.
>
> I have to say, however, that the QGIS core expressions are already quite
> powerful and I don't often have the need to create my own custom Python
> based expressions. I just recently had to use them - but that is the fist
> time after many years ;-)
>
> What is your reason that you have to use Python based expression as opposed
> to the core built-in expressions?
>
> Andreas
>
>
>
> On 07.05.2017 17:01, Stefan Keller wrote:
>>
>> Hi,
>>
>> Tomorrow I'll be giving a Workshop about "Easy Programming QGIS with
>> Python for custom Expression Functions (EFns)" [1].
>>
>> Question 1: Below you'll find an initial list I compiled where EFns
>> are used in QGIS Desktop. => Did I miss an occurrence?
>>
>> Question 2: I tried to make a categorization for several reasons. One
>> reason for this is to realize that a EFn may not work outside QGIS
>> Desktop. Style-related EFns for example won't work currently in
>> qgis2web or QGISCloud. => Any comments?
>>
>> :Stefan
>>
>> [1] https://2017.geopython.net/#schedule
>>
>> List where EFns are used in QGIS (probably incomplete):
>>
>> "Server-side" / data-related:
>> * "Select features using an expression" (Layer property).
>> * "Filtering features" while loading from source. 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)'.
>> * "Layer > Properties > Tab Fields" in Button "Text Edit" in Default-
>> and in Constraints-Field.
>> * "Layer > Properties > Tab Style" in "Label with".
>> * "Field Calculator" to defining new or virtual fields (Layer property).
>> * "Conditional formatting" in the attribute table (Create a new rule
>> and set the condition to the output of a custom EFn).
>> Analysis-related:
>> * "Statistical Summary" Panel (Layer property).
>> * "Atlas Generation" in the Print Composer. Project > Print Composer >
>> Check 'generate an atlas' > Set CEF based values for page name, filter
>> and output filename.
>> "Client-side" / style-related:
>> * "Map Tip" tool (Layer property).
>> * "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"
>> _______________________________________________
>> QGIS-Developer mailing list
>> [hidden email]
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
> _______________________________________________
> QGIS-Developer mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Nyall Dawson
On 8 May 2017 at 06:57, Stefan Keller <[hidden email]> wrote:
> Good question! According to the workshop registrations quite some
> other attendees seem to be interested too at least to know more about
> this :-)

One good reason is that it's a self-contained, achievable task for
users who are new with PyQGIS programming. You can teach this without
having to go into depth about plugin infrastructure/standalone
scripts/etc and instead concentrate on the basics of using the QGIS
python bindings. It's a good way for users to quickly gain confidence
in starting out with PyQGIS.

Nyall
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Tom Chadwin
Re: qgis2web. Nathan enabled expressions with his fantastic qgs2js: https://github.com/NathanW2/qgs2js. There are two ways in which its implementation is incomplete, and I've worked to develop it when I can:

- only a small subset of functions have yet been coded,  and I'd be really grateful for help writing more: see https://github.com/tomchadwin/qgis2web/blob/master/js/qgis2web_expressions.js

- this code is only called in a couple of locations (from memory, labels and rules), so your list could be a huge help

Thanks once again to Nathan for the huge contribution

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

volaya
Tom

I wasn't aware of the qgis2js project. I have borrowed the expressions
code from qgis2web for our WebApp Builder, and was going to prepare a
PR to cotribute back some changes, since i have implemented quite a
few of the missing functions. See, for instance:

https://github.com/boundlessgeo/qgis-webappbuilder-plugin/commit/7fe6f8f894a070a12735f0f8d7ee0376d495d443

https://github.com/boundlessgeo/qgis-webappbuilder-plugin/commit/6828731a95ccd342c0189e42af0f30f15918b1a8

Should I do that against Nathan's repo? Looks like it has less
functions implemented than qgis2web, and you are not actually using it
as a library, but instead you added that code in your repo and are
improving it there. Maybe the qgis2js library should provide some way
of using it as a dependency, so it can be installed in the plugin
folder using pip, for instance, and then we can just work on the main
repo and all improvements will be ready easily for all projects using
it.

I will be happy to work on that, so let me know how i can help

Thanks!

2017-05-08 8:10 GMT+02:00 Tom Chadwin <[hidden email]>:

> Re: qgis2web. Nathan enabled expressions with his fantastic qgs2js:
> https://github.com/NathanW2/qgs2js. There are two ways in which its
> implementation is incomplete, and I've worked to develop it when I can:
>
> - only a small subset of functions have yet been coded,  and I'd be really
> grateful for help writing more: see
> https://github.com/tomchadwin/qgis2web/blob/master/js/qgis2web_expressions.js
>
> - this code is only called in a couple of locations (from memory, labels and
> rules), so your list could be a huge help
>
> Thanks once again to Nathan for the huge contribution
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-Expression-Functions-Where-are-they-used-in-QGIS-Desktop-Which-ones-won-t-work-outsid-tp5319646p5319688.html
> Sent from the QGIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> QGIS-Developer mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Tom Chadwin
Hi Victor

I did do a PR for my few local additions:

https://github.com/NathanW2/qgs2js/pull/2

It would be good to maintain it as an independent repo, if you can be bothered to merge your additions back. Nathan, if you don't want to maintain it, I'd be happy to take it over, or Victor could.

As for how I pull it in, I tried using a git submodule, but I couldn't get it to work very well in all conditions (such as in Travis). That's why I manually copied it in. If you have a better solution, do tell.

I'm reluctant to use eg pip, as it's a barrier to non-tech users. Anyway, I know the question of plugin dependencies has been debated here before, and I'm not sure a good solution was proposed.

Thanks

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Expression Functions: Where are they used in QGIS Desktop? Which ones won't work "outside"?

Nathan Woodrow
Hey Tom and Victor,

I'm happy for you to do whatever want with qgis2js. I can give you full repo write access if you wish to improve it.  I mainly started it to help Tom and it kind of turned into a cool side project but I don't have any real use for it.

Regards,
Nathan

On Mon, May 8, 2017 at 8:58 PM, Tom Chadwin <[hidden email]> wrote:
Hi Victor

I did do a PR for my few local additions:

https://github.com/NathanW2/qgs2js/pull/2

It would be good to maintain it as an independent repo, if you can be
bothered to merge your additions back. Nathan, if you don't want to maintain
it, I'd be happy to take it over, or Victor could.

As for how I pull it in, I tried using a git submodule, but I couldn't get
it to work very well in all conditions (such as in Travis). That's why I
manually copied it in. If you have a better solution, do tell.

I'm reluctant to use eg pip, as it's a barrier to non-tech users. Anyway, I
know the question of plugin dependencies has been debated here before, and
I'm not sure a good solution was proposed.

Thanks

Tom



-----
Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/QGIS-Developer-Expression-Functions-Where-are-they-used-in-QGIS-Desktop-Which-ones-won-t-work-outsid-tp5319646p5319716.html
Sent from the QGIS - Developer mailing list archive at Nabble.com.
_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


_______________________________________________
QGIS-Developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer