My question isrelates to a work-around that I assumed might work, instead of trying this: Count points per polygon, classify point count in original layer in QGIS as all counting attempts have either failed or returned a wrong count number.
I have a layer with polygons (buffers), each polygon has been assigned a unique ID (IDBuffer). I have a second point-layer with the column "neue_bez", in which there are three classes (Kultur, BildungHochschule, NaherholungFreizeit) and a column that assigns each point a unique ID (IDBaupoint), too.
I want to know how many points of each class are within each polygon and I need this information added to the original polygon-layer in three columns (one for each class of "neue_bez"). I know I can get the raw information from a statistic by category, selecting IDBuffer and neue_bez like so:
But as mentioned, I would like a column added for each of the three classes, containing the count for that class per polygon.
This far, I have already intersected the two mentioned layers, so that I now have a layer that contains both IDs (IDBuffer, IDBaupoint), as well as the column "neue_bez" and thus the three classes.
I have since tried the following functions in the attribut table, to create a count-column for the class "Kultur" from the column "neue_bez"- for each polygon
sum(count("neue_bez", group_by:="IDBuffer", filter:="Kultur"))
This just returns 0 for every row.
I tried
count("neue_bez", group_by:="IDBuffer")
But this just returns the overall count of points per polygon and doesn't classify them.
Lastly, another idea I had was:
sum("neue_bez",group_by:="IDBuffer",filter:="Kultur")
Which doesn't work/is invalid, because right now I'm asking it to sum up "neue_bez", although the content is not numerical. If I created a column that just held the value "1" in each field to represent the amount of entries, could this then work, including the two expressions of group_by and filter?
Are there more elegant ways of doing this than my last idea?