0

How to make an intersection function condition for a field calculator?I have three layers-buildings, parcels_old, parcels_new.In the layer of buildings i need to move parcel number ("n_parc" field).If there is an intersection with the layer 'parcels_old' the buildings need their number, if there is an intersection with 'parcels_new' the buildings need their number, if there is an intersection with both layers, the number from the layer 'parcels_new' is needed . enter image description here

2
  • I suggest running the `intersection´ tool twice and then using the field calculator to keep the parcel numbers as you wish to.
    – Erik
    Feb 13, 2023 at 15:12
  • @Erik Thank you! I did, but I wanted to automate this field for new objects.
    – Ivan M
    Feb 14, 2023 at 7:04

1 Answer 1

1

You can use a simple if condition to check whether there is a value for the new parcels. If not take the value of the old parcels. If there are values for the new parcels, take those.

if(array_length(overlay_intersects('parcels_new',"n_parc"))=0,
array_to_string(overlay_intersects('parcels_old',"n_parc")),
array_to_string(overlay_intersects('parcels_new',"n_parc"))
)
1
  • Thank you! Great solution!
    – Ivan M
    Feb 14, 2023 at 7:10

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.