2

I'm using QGIS 3.12.1 on Win10 x64.

Overview I have a point layer representing tree positions. I have a calculated field ("rpaR") based on other attributes. I am using the geometry generator in styling to create a buffer around the point.

When I create a point, the geometry generator styling is not displayed. If I then edit that point, changing any attribute, it works. I thought this might be because the calculated field "rpaR" on which the buffer is based was not calculated before saving the new feature, but: (1) I can see the "rpaR" value is there before I save. If I then edit and change an underlying feature that changes the value of the "rpaR", the amended geometry generator styling is implemented immediately.

DETAIL

First, the drag and drop designer, showing the settings for the calculated field rpaR. The expression is as follows:

( if("dbh1" is null,0,("dbh1" / 1000)^2 * "stems1") + if("dbh2" is null,0,("dbh2" / 1000)^2 * "stems2") + if("dbh3" is null,0,("dbh3" / 1000)^2 * "stems3") + if("dbh4" is null,0,("dbh4" / 1000)^2 * "stems4") + if("dbh5" is null,0,("dbh5" / 1000)^2 * "stems5") )^0.5

I note the text tip below the default value field reads "column 'dbh1' not found". I think this is sympomatic of the same issue. After saving the feature and amending any field, 'dbh1' is found and this tip reports the correct value. rpaR setting

Second, the geometry generator field. geometry generator setting

Third, plotting the feature (ref arrow) before saving (pressing OK). rpaR has been calculated correctly (blue arrow). plotting the feature - before saving

Four. Feature has been plotted - red arrow. But neither the simple marker, nor the geometry generator are displayed. enter image description here

Five. I edit the feature and change any field. Press OK. Now the geometry generator has created the dashed blue line (red arrow). Also, at the feasture centre, the simple marker is also displayed. enter image description here

Is this a bug, or some unseen error by me?

0

1 Answer 1

4

I tested out your scenario (I use a very similar arrangement myself). I assume here that none of your underlying fields (dbh etc) are not joined from another layer. The column ... not found preview is quite common in the form designer if there are no features in the layer, or the first feature has a NULL value in that field.

The issue seems to arise because the rpaR widget has been set to not editable. The default value calculation does not seem to play well when editing is disabled in the form designer.

In this instance where you don't want your calculated value to be editable, may I suggest using a virtual field. Unfortunately you won't see the real-time calculation in your form but it will show up instantly in your data and styling.


Here are two examples where the field tpz has a default value of "dbh_cm"*0.12 and is buffered with a geometry generator shown in blue; tpz_virt is a virtual field with the same expression, similarly buffered but with a pink dashed line.

Widget not editable (or not visible in form) - tpz auto-updates in form but does not save values (no geometry generator).

enter image description here

Widget editable - tpz auto-updates in form and does save values.

enter image description here


Note also that this applies if your geometry generator style is applied to the same QGIS layer that you are editing. I often duplicate the source data to 2 layers, one styled as point markers and the other styled with a geometry generator, and do all my editing in the points layer. In this case, the geometry generator will only update when the point layer is saved.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.