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.


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.

Any help appreciated.

  • 2
    How do you calculate "rpaR"? Can you provide a reproducable example with the exact steps taken? If you are sure it is a bug, consider reporting it directly on QGIS issues site. – MrXsquared Apr 21 '20 at 15:08
  • Hi. Thanks for the reply. No I'm not sure it's a bug. I wanted to explore here before reporting it if it is my error. The default value of "rpaR" is set to the expression below, which works. ( 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 have apply default value on update ticked. – Oisin Apr 21 '20 at 15:20
  • I'll take some screenshots and post them – Oisin Apr 21 '20 at 15:22
  • Please Edit the question in response to requests for clarification in comments. – Vince Apr 21 '20 at 15:56

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.

  • as an addendum - not related to your question, but could I also suggest using coalesce() in your expression to make it more concise? You could rewrite it as (coalesce(("dbh1"/1000)^2*"stems1",0)+ coalesce(("dbh2"/1000)^2*"stems2",0)+ coalesce(("dbh3"/1000)^2*"stems3",0)+ coalesce(("dbh4"/1000)^2*"stems4",0)+ coalesce(("dbh5"/1000)^2*"stems5",0))^0.5 – she_weeds Apr 23 '20 at 1:44
  • Many thanks for this. I haven't had a chance to test it out yet, but I will and will let you know how I get on. Thanks again. – Oisin Apr 25 '20 at 13:19
  • Hi @Oisin - did changing the field with calculated values to Editable work for you? – she_weeds May 4 '20 at 3:44
  • Hi @she_weeds. Sorry about the delay in replying. Still very busy at work, despite COVID. It worked a little, but not entirely. It now works, except for the 1st tree digitized in each session. There are various things I’m exploring. 1. Avoiding the use of my field dbh_equiv or rpaR (which were populated by expressions in default values), and just using a longer expression built up from the dbh1 to dbh5 and stems1 to stems5 fields. 2. Using virtual fields. 3. Using symbology generator on the original layer, a duplicate layer, or creating a virtual layer I’ll let you know how I get on. O – Oisin May 10 '20 at 13:37
  • 1
    Now working. I've used a virtual field (vRPA) to calculate the RPA because the user may need to see the value. I've then created the RPA as virtual layer - buffer($geometry , vRPA). Crown spread is still a geometry generator, but as you suggested as a duplicated layer. Because there's no intermediary calculated fields it seems to work fine. Thanks for your input. – Oisin May 10 '20 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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