1

Currently, I have a vector layer with polygons in it and another layer with points. There is a column with an exact time stamp in the points layer; I would like to determine the time stamp for the earliest point in each polygon (note - some polygons might not have a point in it.) There are probably 20,000-25,000 polygons in this layer, so unfortunately I can't do this polygon-by-polygon. Once I've identified the earliest point, I'd then like to create a column in the polygon with its time stamp. Any intuition on how I can do this?

2
  • This is basic tabular statistics. You can join on the fly or intersect once, then SELECT min(datecol) with a GROUP BY of polygon ID.
    – Vince
    Commented Feb 14, 2023 at 14:15
  • Thanks for the reply. I just added another sentence toward the end of my question. From there, how could I then create a column in the polygon with the time stamp of the earliest point? Commented Feb 14, 2023 at 14:22

1 Answer 1

1

You can easily do this by adding a virtual field to your Polygon layer:

array_min(overlay_intersects('point_layer_name',timestamp_attribute_name))

This will handle finding the minimum timestamp within each given polygon and setting it as an attribute for each polygon

Polygons with no points inside will have a NULL attribute

Applying it to a layer where I search theRandom points minimum Id attribute value, assigned to an earliest field.

enter image description here

Points labels are their Id, Polygon label in red is the earliest field attribute

enter image description here

Changes to either layer are handled dynamically:

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.