qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.65k stars 3.01k forks source link

Using Classify in Symbology dialog does not return all boolean values #40068

Open DelazJ opened 4 years ago

DelazJ commented 4 years ago

In Layer Properties, Symbology, Categorized, using an expression returning a boolean does not seem to always return all possible values, ie 0, 1 (and all other values) See classes of gid=attribute(@atlas_feature, 'gid'), gid=12 and gid='toto' below

note:: While the expression preview shows 0 or 1 in the screencast, I get the same "bug" for expressions that previews as true/false (eg, is_selected( @atlas_feature))

classifyButton

QGIS version 3.16.0-Hannover QGIS code branch Release 3.16 (9e55f5e99)
Compiled against Qt 5.12.8 Running against Qt 5.12.8
Compiled against GDAL/OGR 3.0.4 Running against GDAL/OGR 3.0.4
Compiled against GEOS 3.8.0-CAPI-1.13.1 Running against GEOS 3.8.0-CAPI-1.13.1
Compiled against SQLite 3.31.1 Running against SQLite 3.31.1
PostgreSQL Client Version 12.4 (Ubuntu 12.4-0ubuntu0.20.04.1) SpatiaLite Version 4.3.0a
QWT Version 6.1.4 QScintilla2 Version 2.11.2
Compiled against PROJ 6.3.1 Running against PROJ Rel. 6.3.1, February 10th, 2020
OS Version Ubuntu 20.04.1 LTS This copy of QGIS writes debugging output.
Active python plugins db_manager; MetaSearch; processing
roya0045 commented 4 years ago

if you use "gid"=12, does that work? Wait ther are no 12 in your data...

The classify will only return observed values, not possible values. If the tool would return all possible values you would have millions of values all the time, this doesn't make sense.

roya0045 commented 4 years ago

I'm pretty sure this one isn't a bug, if you want to represent a value that isn't present just add it manually. The tool doesn't see it as boolean but as integer.

DelazJ commented 4 years ago

The classify will only return observed values, not possible values. If the tool would return all possible values you would have millions of values all the time, this doesn't make sense.

gid = 12 as an expression is a boolean check, not an integer. It checks whether the field has value 12 or not. not checking what possible values the field should have. And for a boolean, possible values are true or false nothing more. Now if you say; it returns observed values, it explains the gid=12 outputs (0) but not the empty output for toto (should be 0) or atlas_feature ones (should be 0 and 1).

roya0045 commented 4 years ago

As for toto the only value observed is false because gid is never = toto. the atlas feature one is a toss up depending if th atlas is active, not sure about the preview.

DelazJ commented 4 years ago

As for toto the only value observed is false because gid is never = toto.

Yes, the 'toto' case would also be OK, for observed values. I doesn't output an empty value as I said just above.

the atlas feature one is a toss up depending if th atlas is active, not sure about the preview.

Of course the atlas is active, otherwise the preview wouldn't evaluate to 0 or 1 and these results are correct. If inactive, I guess you'd get either 0 or Null (didn't check and this is not the point here). If "Classify" returns the observed values, it should return what the preview shows. If not, then one of them is buggy.

roya0045 commented 4 years ago

Only the cas of the atlas feature is a valid bug to me. Evaluating an '=' can never be null, only 0 or 1.

Pedro-Murteira commented 2 years ago

Still valid on QGIS 3.22.4. and 3.24.0.