# Spatial join and sum of attributes between 2 layers

I have on a spatial join issue : I need to perform a spatial join from a building shapefile to a grid feature class (200 * 200 meter). The spatial join needs to compute the sum of each attribute per tile.

More precisely, i have several attribute (income, surfaces, number of people per buildind, ages, children and so on). The aim is that each building within a tile has to be concatenate. For example, if within a tile, there is 2 buildings, one of 60 m² and the other is 40 m², the result of the tile in the field surface must be 100 m².

Does someone know how to solve this problem ?

• What geometry type is your shapefile, and I would recommend learning some SQL spatial and using DBManager to intersect your data using ST_Intersects() function Sep 11, 2017 at 15:09

It's the french INSEE grid, isn't it ?

The method your are looking for is with an Intersect tool type.

The following doesn't exactly answer your question, but i'll give you the method I use on this specific data :

• I first transform buidings into real centroids (to avoid centroids being outside the buildings). Having points will avoid having a building cut in half on two cells.

• Then attribute a simple unique ID to your grid cells by creating a UID field (INSEE naming is useless)

• Use a "join attribute by location" Tool to get the UID in the centroid layer.

• Join the building layer and the centroid layer by their common unique id (BD TOPO type id looks like "BATIMENT0000000221921558") and update the cell UID in a new field of your building layer (CELL_ID for example).

• You will then be able to use the cell ID to get to the source values (like the population number) or group the buildings by cell id. You can for example create in Excel a simple pivot table (tableau croisé dynamique) to get the total surface for each cell of your grid.

I finally used the intersect tool (on arcgis) with sum as output field properties, and it's perfectly working.

(It was indeed the INSEE grid, good job ;) ! )