4

I'm having a bit of a headache on this one, I hope you'll be able to help me out. (I'm on QGIS 3.10)

Problem

Here is the case : the national Dutch zoning plan regulation is delivered with shapes in which the maximum building height is stated. Unfortunately, they keep in the dataset current and previous zones. I would like to keep only the ones that are applicable on a national scale.

I have multiple features (in my case buildings) that are overlapping and/or being duplicated in one single layer. When there is an overlap, I would like to keep the geometries that are with the attributes the closest to current date.

My understanding would be that overlapping geometries should be compared and the one with the date attribute closest to today's date should be kept.

Done so far

But so far no success, with multiple methods I could try :

  • Filtering out by dates doesn't make sense as depending on where you are in the country, the latest plan might be more or less old.
  • There is no exhaustive list of attributes which could make the trick by filtering out the ones that are considered outdated by the municipalities.
  • Join Attributes By Location doesn't work in this case.
  • Delete Duplicates works but there is no control over which one is deleted, meaning that some times it is an outdated rule that is being kept.
  • Vector Overlay hasn't worked neither.

As the data I'm dealing with is country scale, I cannot rely on manual sorting... :/

Any help would be AMAZING!

Building code outdated in blue (large zone)/Building code to be kept in yellow

1 Answer 1

4

You can solve it using this expression in the tool Select by Expression

if("datum" = 
  array_last( 
    array_agg(
    expression:= "datum",
    filter:=
      array_length(
      array_agg( 
      expression:=$geometry,
      group_by:=geom_to_wkt($geometry)))>1,
    group_by:=geom_to_wkt($geometry)
    )
  )
, $id, '')

The expression will check all the duplicates geometries that are completely overlapping and it will select the one with the older date stored in the field "datum".

The expression I am suggesting to you have been created some days ago by me in collaboration with pigreco and an explanation (in Italian language) of the code used is available at this address

7
  • That is helpful! I applied the method which worked perfectly on complete duplicate geometries. In the case of overlapping geometries (ie. on geometry inside or intersect another one) it doesn't seem to work. Instead of comparing the wkt, would you think of an alternative to compare geomtries and see if intersection or inclusion there is?
    – Max
    Jul 13, 2020 at 19:41
  • Unfortunately, the $geometry is not a comparable value. This is the reason we opted for WTK. The location is the only attribute that the features have in common? No other attributes such a name or code?
    – Val P
    Jul 13, 2020 at 19:45
  • Thanks again for your reply. I could find a common attribute "aanduiding" (string including symbols). This attribute is common if it was a geometry that existed beforehand and that has been subdivided or joined. So this might do the trick. But I'm trying to insert it into the expression you provided but I cannot seem to make it work. Would you have something to indicate how I could insert the additional filtering by the common attribute? Thanks a lot again for your valuable help!
    – Max
    Jul 14, 2020 at 9:15
  • 1
    Try to replace geom_to_WTK($geometry) with the name of your field in both group_by. It should work. It will select all the geometry with duplicated attribute and remove the one with the older date. But your issue is starting to be far from the original question and to answer you properly I need to see your data set.
    – Val P
    Jul 14, 2020 at 9:20
  • Also, if the answers help you, consider to accept it to let more people know that it works.
    – Val P
    Jul 14, 2020 at 9:21

Your Answer

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

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