0

The situation I have a point layer ("Beobachtungen") and a single part polygon layer ("Single parts"). For both layers, every feature has a unique id.

As shown in the image, some points are within a polygon of "Single parts" and some are not.

The features of the point layer have a date field ("Datum" ; format: dd-MM-yyyy).

The task: I want to select all features from "Beobachtungen" that are within the same polygon AND share the same value for the field "Datum" . The value for the field "Datum" can be any possible date, not a specific one. Furthermore, I then want to keep only one of those features and delete the other duplicate(s). Which one to keep can be random.

enter image description here

Hannes
  • 129
  • 7
  • If the result is a new layer (dataset) is that ok? – Aquamarine Mar 18 '24 at 19:16
  • Yeah I think that shouldnt be a problem. – Hannes Mar 19 '24 at 04:19
  • Do you need to retain point features that do not match the date on the enclosing polygon? – Aquamarine Mar 19 '24 at 13:51
  • definitely yes. and please be aware of the fact that it's not about a specific date of but any possible date that occurs at least two times inside the same (!) polygon. I searched very much for the answer but couldn't make it up to now. I guess I just need the right expression for "select by expression". It would be even enough to just select duplicates that are within the same polygon. I could do the delete-thing manually afterwards. your help is much appreciated! – Hannes Mar 19 '24 at 15:53
  • Another question! So you want to select all point features where the date of the point feature is the same as the date of the enclosing polygon and if there are more than one points with that date in the polygon, delete the duplicates. And leave all other points as they are - is that correct? – Aquamarine Mar 19 '24 at 20:11
  • No. I want to select Point Features, that have the Same Date as other Point Features but Only those, that are within the Same Polygon. For example Point Features ID1 & ID2 have the Date 01.01 2024 and are within Polygon ID 5. I want to delete one of both Point Features. But: If there is any other Point Feature ID3, that also has this Date but is Not within this Polygon, it has to be retained! The number of Point Features, that have to be deleted can be any number as there may be multiple Points with Same Date within the Same Polygon. Think of it like "delete duplicates within same polygon" – Hannes Mar 20 '24 at 10:09
  • Do you need to be able to pass the date as a parameter or should all features that are within a polygon that share the same date be replaced by one feature? – Aquamarine Mar 20 '24 at 13:48
  • see the original question. one of the features should be kept (with all its attribute fields and values). it would be no problem to create a new feature at the exact same coordinates as one of the old ones but in any case the attribute fields and their values have to be retained – Hannes Mar 20 '24 at 14:28
  • Ok - i've a proposed solution posted below – Aquamarine Mar 20 '24 at 15:14

1 Answers1

1

This might work if my interpretation is correct:

  1. Run Join attributes by location creating layer Joined
  2. Select from the joined table those features that joined and run Delete Duplicates by attribute using the date field from the point layer and the key field from the polygon overlay layer with the selected features only option ON. This will create a layer that has a single point for any instance of date duplicates within a polygon and will also include any point features that don't have duplicates.
  3. Export features from Joined that have null in polygon key field to layer called Features not in overlay (they are located outside of all polygons)
  4. Run Merge Vector Layers - 2 layers as input to merge: a) the output from Delete Duplicates by Attribute and b) Features not in overlay

Input:

enter image description here

Result: enter image description here

Aquamarine
  • 1,176
  • 5
  • 12