Bug report #19900
Compute min/max/sum/mean (stats) while Dissolving layer not working (GDAL tool)
Status: | Closed | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | GDAL Tools | ||
Affected QGIS version: | 3.2.3 | Regression?: | No |
Operating System: | Windows 10 | Easy fix?: | Yes |
Pull Request or Patch supplied: | Yes | Resolution: | |
Crashes QGIS or corrupts data: | No | Copied to github as #: | 27724 |
Description
The Dissolve and calculate the Statistical Values of a numerical field operations, performed by the GDAL tool, results in incorrect values. Instead of calculating the statistics on the field indicated in the menu "Compute min / max / sum / mean for X attribute", it is done on the field "Dissolve Field". The console's own message shows it: ogr2ogr "C:/Users/Facu/Downloads /Facu QGIS1 /Brandsen/Shape/test.gpkg" path_to_data_file -dialect sqlite -sql "SELECT ST_Union (geometry) AS geometry, Name, SUM (Name) AS sum, MIN (Name) AS min, MAX (Name) AS max, AVG (Name) AS avg FROM layer_name GROUP BY Name "-f" GPKG".
The calculation should be done on the indicated numerical field (e.g. Population), not on the one used to perform the dissolution (e.g. State_name), which is not a numerical.
Regards
Associated revisions
[processing][gdal] Add unit tests for Dissolve algorithm
Also:
Thanks to @agiudiceandrea:
Fixes #19900
Statistics were erroneously computed on the dissolve field, rather than on the statistic attribute field as it should be.
Fixes #19307
Handle filenames with white spaces (in the same way as Buffer, OffsetCurve, OneSideBuffer, PintsAlongLines algs).
History
#1 Updated by Andrea Giudiceandrea about 6 years ago
PR https://github.com/qgis/QGIS/pull/7964 submitted for QGIS 3.3.0-master
You can fix your Dissolve algorithm python script by changin line 157 in [QGIS install dir]\apps\qgis\python\plugins\processing\algs\gdal\Dissolve.py
from
statsField = self.parameterAsString(parameters, self.FIELD, context)
to
statsField = self.parameterAsString(parameters, self.STATISTICS_ATTRIBUTE, context)
#2 Updated by Alessandro Pasotti about 6 years ago
- Pull Request or Patch supplied changed from No to Yes
- Status changed from Open to In Progress
Please update status and "PR/patch supplied" if you are working on a bug, this spares some clicks to other developers looking for tickets to work on.
#3 Updated by Andrea Giudiceandrea about 6 years ago
I'm not allowed to update the bug status.
#4 Updated by facundo pedemonte about 6 years ago
Andrea Giudiceandrea wrote:
PR https://github.com/qgis/QGIS/pull/7964 submitted for QGIS 3.3.0-master
You can fix your Dissolve algorithm python script by changin line 157 in [QGIS install dir]\apps\qgis\python\plugins\processing\algs\gdal\Dissolve.py
from
[...]
to
[...]
Thanks, this solved the issue.
#5 Updated by Nyall Dawson about 6 years ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
Applied in changeset qgis|a3af1f9f3a3e997614ffe8577be930a62c30fcc6.