Bug report #14301
simplification makes geometry-based expression values (such as $area) vary for symbology and labels
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22292|
When simplification is activated for a given vector layer, geometry-based expression values - such as $area - will vary within a symbology or label context when the zoom level in changed. I haven't looked at the code, but what I'm assuming happens here is that the expression is run against the simplified geometry, leading to varying values as the geometry is morphed.
That's a significant shortcoming that would be worth addressing. I discovered this when a number of polygons were going missing in a project using a density-based expression to make a graduated symbology.
I'm attaching a small test project to this issue that shows a polygon disappearing when zooming out (due to simplified polygon having an erroneous $area value).Steps to reproduce
- Open the attached project
- Notice the rule-based expression being used: ($area / 10000) > 1309 AND ($area / 10000) < 1310
- Zoom out onto the canvas a couple of times, you'll see the polygon go missing
If you change the symbology to a single symbol, you can zoom in and out and notice the label (which shows the result of the following expression: $area / 10000) value varies as the simplified polygon returns different $area values.