[Qgis-user] QGIS 3.22 - Geometry by expression howto

Francesco Pelullo f.pelullo at gmail.com
Sun Jan 1 10:22:20 PST 2023


Hi Nicolas,

Il giorno dom 1 gen 2023 alle ore 04:53 Nicolas Cadieux <
njacadieux.gitlab at gmail.com> ha scritto:

> 
>
> Try decimal with commas. Check your local system settings.  Could this be
> a wrong CRS problem?  Try zoom to layer extent to see if they pop up in the
> wrong place.  Share a few examples so we can check. Try  exporting the
> geometries to Wkt in a new field to see what happens….
>

Thank you for your suggestions, particularly the "geom_to_WKT", it let me
discover problem.
IMHO this is a bug in "geometry by expression" algorithm.

By my exoeriences, this algorithm works _only_ if source layer has at
almost one feature.
If so, you can add new feature by this expression:
make_point(to_real(@Long),to_real(lat))
where @Long and @Lat are two project variables. Everything works as
expected.

Otherwise, e.g. when the source layer has no feature (empty layer), the
geometry by expression fails and return <null> geometry, even if the
preview in expression generator is correct.

In my test, i was usual to truncate the source layer before generate new
geometry.
This caused the fail of geometry by expression algorithm.

Instead, if i don't truncate source layer (and it has at almost one
geometry before running the model), then the algorithm works.

This is a bit confusing, because in the  "geometry by expression"
documentation there is no reference to this condition.
Could this be a bug?
Is it possible to add new features to a empty layer with geometry by
expression?

Again, thank you to everyone and have a nice year!

Francesco
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20230101/69084752/attachment.htm>


More information about the QGIS-User mailing list