1

In QGIS, is it possible to count the features of each class in a categorized layer where the features being counted are limited to those that are inside the current atlas feature?

Feature count for all features in the layer

I have tried turning on "Filter Legend by Map Content" combined with the filter expression intersects($geometry,@atlas_geometry), but the result remains the total feature count, and, is not restricted to the feature count of the atlas feature.

I am aware that I can count features within an atlas feature using a label, but, then it is not part of the legend.

0

One solution is to make a virtual layer that that summarises the layer, and, then add an attribute table to the print atlas. For example, if the following query is used to create a virtual layer:

SELECT atlas_polygon.name, points.class, SUM(points.number) AS number, COUNT(points.class) AS location, atlas_polygon.geometry
FROM points
INNER JOIN
atlas_polygon
ON
st_intersects(points.geometry, atlas_polygon.geometry)
GROUP BY atlas_polygon.name, points.class

Then it's results will be shown for each atlas feature bu checking the box "Show only features intersecting atlas feature" in the attribute table on the Print Layout.

Attribute Table settings on the Print Layout

It would be awesome to also show the layer symbols on the attribute table Print Layout but that is another problem.

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.