Skip to main content
deleted 39 characters in body
Source Link
Kadir Şahbaz
  • 78k
  • 57
  • 257
  • 404

It's taken me nearly 8 years but I finally found the answer!

  1. Open Field Calculator to update field "VALUE_A" in Layer A, and use the following expression:
  • aggregate('Layer B', 'sum', "VALUE_B", within(centroid($geometry), geometry(@parent)))
    

...................... Open Field Calculator to update field "VALUE_A" in Layer A, and use the following expression:

aggregate('Layer B', 'sum', "VALUE_B", within(centroid($geometry), geometry(@parent)))

Use Show Help to learn other functions you can use in each of the arguments:

  • aggregate(layer,aggregate,expression[,filter][,concatenator=''][,order_by])
    
aggregate(layer,aggregate,expression[,filter][,concatenator=''][,order_by])

I have found this does time out for larger datasets, if this is an issue then you can select a subset of overlapping polygons in both Layer A and Layer B, check 'Only update selected features' (in Layer A), and use the following modified expression:

  • aggregate('Layer B', 'sum', "VALUE_B", is_selected('Layer B', @feature) AND within(centroid($geometry), geometry(@parent)))
    
aggregate('Layer B', 'sum', "VALUE_B", is_selected('Layer B', @feature) AND within(centroid($geometry), geometry(@parent)))

Finally, if you wanted to update with a text value from the containing polygon you can use 'min''min' as the aggregate instead of 'sum''sum'.

:)

It's taken me nearly 8 years but I finally found the answer!

  1. Open Field Calculator to update field "VALUE_A" in Layer A, and use the following expression:
  • aggregate('Layer B', 'sum', "VALUE_B", within(centroid($geometry), geometry(@parent)))
    

......................

Use Show Help to learn other functions you can use in each of the arguments:

  • aggregate(layer,aggregate,expression[,filter][,concatenator=''][,order_by])
    

I have found this does time out for larger datasets, if this is an issue then you can select a subset of overlapping polygons in both Layer A and Layer B, check 'Only update selected features' (in Layer A), and use the following modified expression:

  • aggregate('Layer B', 'sum', "VALUE_B", is_selected('Layer B', @feature) AND within(centroid($geometry), geometry(@parent)))
    

Finally, if you wanted to update with a text value from the containing polygon you can use 'min' as the aggregate instead of 'sum'.

:)

It's taken me nearly 8 years but I finally found the answer!

Open Field Calculator to update field "VALUE_A" in Layer A, and use the following expression:

aggregate('Layer B', 'sum', "VALUE_B", within(centroid($geometry), geometry(@parent)))

Use Show Help to learn other functions you can use in each of the arguments:

aggregate(layer,aggregate,expression[,filter][,concatenator=''][,order_by])

I have found this does time out for larger datasets, if this is an issue then you can select a subset of overlapping polygons in both Layer A and Layer B, check 'Only update selected features' (in Layer A), and use the following modified expression:

aggregate('Layer B', 'sum', "VALUE_B", is_selected('Layer B', @feature) AND within(centroid($geometry), geometry(@parent)))

Finally, if you wanted to update with a text value from the containing polygon you can use 'min' as the aggregate instead of 'sum'.

Source Link
Nataniel
  • 73
  • 1
  • 6

It's taken me nearly 8 years but I finally found the answer!

  1. Open Field Calculator to update field "VALUE_A" in Layer A, and use the following expression:
  • aggregate('Layer B', 'sum', "VALUE_B", within(centroid($geometry), geometry(@parent)))
    

......................

Use Show Help to learn other functions you can use in each of the arguments:

  • aggregate(layer,aggregate,expression[,filter][,concatenator=''][,order_by])
    

I have found this does time out for larger datasets, if this is an issue then you can select a subset of overlapping polygons in both Layer A and Layer B, check 'Only update selected features' (in Layer A), and use the following modified expression:

  • aggregate('Layer B', 'sum', "VALUE_B", is_selected('Layer B', @feature) AND within(centroid($geometry), geometry(@parent)))
    

Finally, if you wanted to update with a text value from the containing polygon you can use 'min' as the aggregate instead of 'sum'.

:)