2

So, I have a dataset of many points across Europe. For illustration purposes see this image below:

enter image description here

Each of these points has one of four categories attached to it, so the dataset I am working with has points with X and Y coordinates, and these categories are A, B, C and D.

What I would like to do then is to overlay a grid of a certain dimension over these points like here:

enter image description here

To then count the share of each of the points in one of the grid cells and map them out, to create four different maps for the four different categories that I have showing for each category what is the share in each of the grid cells.

So for example, if in one of the grid cells we have 10 points, 5 belong to category A and 5 to category B the share for each category in that grid cell would be 0.5. In the end, I would like to end up with four raster maps for each of the categories, where each pixel shows the share of the points of that category in that grid cell.

Illustration here:

enter image description here

I found similar questions like this: Counting occurence of unique points across large grid using QGIS? but usually it is just about a number of points per grid cell, whereas I need the share of points for each of the four categories. Any ideas?

1
  • 2
    It's certainly doable. What have you tried? Right now you have a task detailed, but not a problem for our problem-solving site.
    – Vince
    Oct 31, 2023 at 12:46

1 Answer 1

0

On the grid layer, use the following expression and adapt the name of the point layer, the attribute field name and the filter condition accordingly:

array_length(
    overlay_contains(
        'points',  -- adaper layer name
        "category", -- adapt field name
        filter:=category='A', -- change filter condition
        limit:=-1
    )
)/
array_length(
    overlay_contains(
        'points', -- adaper layer name
        "category", -- adapt field name
        limit:=-1
    )
)

The expression in action, here as source of a label (in red), counting the share of the points with "category" = 'A' of the total points in each grid cell: enter image description here

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.