2

I want to count points by polygon but I don't have well-defined polygons. Instead I have a categorical variable:

Map

I have created a different layer for each categorical variable (that's why each of them have different colors).

How do I combine all the polygons of one layer in one non-continuous polygon?

The final goal is counting all the points of another layer.

For example if I want to count points in a USA map, Alaska, Hawaii and another non-contiguous territories would count as well.

1 Answer 1

4

Your proposed approach would work, but you run the risk of long processing times in cases where you have many polygons, as you could create extremely complex geometries. To make non-continuous polygons (called "MultiPolygons"), you can use the tool Vector Geometry > Collect Geometries and specify your category attribute in the Unique ID fields parameter.

However, in cases which I mentioned, which could involve many polygons, you could use a slightly longer but also effective solution:

  1. Make sure your point layer has a unique id field

  2. Run Vector General > Join attributes by location (summary), with your polygon layer as Input layer and the point layer as Join layer. In Fields to summarise, specify the unique id field in the point layer. In Summaries to calculate, specify count

  3. You will now have a new joined layer. Run Vector Analysis > Statistics by categories on this layer. Specify Field to calculate statistics on as [point layer id unique name]_count, and specify the polyon layer's category attribute name in Field(s) with categories.

  4. You now have a table count the number of points which coincide in each category. You can probably also see in the previous steps how you could calculate other interesting statistics, like minimum, maximum, average, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.