There is a polygon layer "Union23"
that was created with 'Union'
tool.
Layer's attribute table includes the following values.
My effort is simply to aggregate those polygons by "FLAECHEID"
field with the sum and count of a field "In_Value1"
via Virtual Layer. So I am using the expression
SELECT *, SUM(In_Value1), COUNT(In_Value1)
FROM Union23
GROUP BY "FLAECHEID"
However, I am getting really weird output and I do not understand why I am losing a part of geometry on the way? Any suggestions?
When I use the solution offered by @JGH I am somehow getting better output but still with small issues. It is most like related to the original geometry. Improving geometry is necessary as was mentioned by @Stu Smith.
References:
Answer
When using a mix of an aggregate function and a regular row, SQLite will return a random row for the not-aggregated field (see doc, point 3). To overcome this, don't use *
but properly aggregated fields, including on the geometry
SELECT ST_UNION(geometry), SUM(In_Value1), COUNT(In_Value1)
FROM Union23
GROUP BY "FLAECHEID"
No comments:
Post a Comment