3

I have a series of occurrence points that I am trying to downsample to 1/20 km to avoid sampling bias. So far, I have made a grid of ~20km squares and have filtered them down to squares with more than one occurrence point in them.

I want to figure out how to randomly select a single point within each grid square and delete the rest in the square. I tried joining the point vector and grid vector layers as was suggested in this post, but whenever I try to filter by longitude or ID, it selects every point in every square except one.

Does anyone know either what I'm doing wrong that's preventing me from selecting points randomly or a simpler method to doing this?

Here's an example of the squares with the occurrence points

1 Answer 1

2

If you have a polygon layer with several points in it, you can randomly select one point per polygon by applying this expression on the polygon layer to create new geometries (see how to do it). Replace 'points' with the name of your points layer:

closest_point( 
    aggregate (
        'points', 
        'collect',
        $geometry
    ),
    $geometry
)

Screenshot: you see that one white dot (created here with geometry generator) per polygon is created above the red points:

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.