# Segment attribute according to percentage of overlapping area

My project have a layer of GRID polygons with the value of Population ("POBTOTAL"). On the other hand, there is a SECC polygon layer with the neighborhoods division.

And I add a screenshot of the approach:

My goal is to assign the GRID Population to each SECC polygon, segmenting the value according to the percentage of area that represents each polygon of the SECC layer on GRID layer. Here I make a simulation of the population values assigned to the SECC polygons:

There are cases where a SECC polygon intersects with two or more GRID polygons. In this case it would be necessary to summarize the values:

Calculate a new floating point field on the "SECC" layer, using `aggregate` this way:

``````aggregate(
layer:='GRID layer name/id', -- set here your layer name
aggregate:='sum',
expression:="POBTOTAL" / \$area * area(intersection(\$geometry, geometry(@parent))),
filter:=intersects(\$geometry, geometry(@parent))
)
``````

Proposed solution

I have tested the following solution based on geoprocess Vector overlay -> Intersection

On GRID layer:

1. Execute Intersection geoprocess

On Intersection layer:

1. Calculate: \$area
2. Calculate percentage area : AREA/AREA of GRID
3. Calculate segmented POB: POBTOTAL*PERCENT

On SECC layer:

1. Spatial connection with the intersection layer using the expression developed by the user Babel (https://gis.stackexchange.com/users/88814/babel) in the answer to the question (Joining two polygons where they overlap the most in QGIS):
``````array_first (
overlay_intersects(
'Intersection',  -- Replace with the name of the layer
POBPERCENT,
sort_by_intersection_size:='des'
)
)
``````

With this solution I will be able to finish the project matching for each SECC polygon a segmented proportion of the population in its proportional area: