title: Intersection Area of 'n' shapefiles - Python
body: <p>I have 'n' shapefiles and where they intersect i need to sum a specific attribute. In some points they all intersects, in other points only some of them intersects while in others i don't have any intersection. My final results would be a single shapefile (union of the 'n' shapefiles') where for each intersection area i get the sum of a specific attribute. Is there an easy way to do it, without converting to raster? I already tried with the Geopandas "Overlay" function but without iterating many times i can only get the area where all the shapefiles intersect and not where only some of them intersect.</p>
  
  <p>you can find the shapefiles here: <a href="http://www.mediafire.com/folder/2ckfxkfda0asm/shapes" rel="nofollow noreferrer">http://www.mediafire.com/folder/2ckfxkfda0asm/shapes</a></p>
  
  <pre><code>import pandas as pd
  import geopandas as gpd
  g1 = gpd.GeoDataFrame.from_file("shape1.shp")
  g2 = gpd.GeoDataFrame.from_file("shape2.shp")
  g3 = gpd.GeoDataFrame.from_file("shape3.shp")
  g1['number'] = pd.to_numeric(g1['number'])
  g2['number'] = pd.to_numeric(g2['number'])
  g3['number'] = pd.to_numeric(g3['number'])
  df = pd.concat([g1,g2,g3])
  intersection = g1
  simmetric = g1
  lista = [g2,g3]
  for i in lista:
      intersection = gpd.overlay(intersection, i, how='intersection').fillna(0)
      intersection.index = pd.RangeIndex(len(intersection.index))
      intersection.loc[:,'number'] = intersection.loc[:,'number_1'].add(intersection.loc[:,'number_2'])
      intersection.drop(["number_1", "number_2"], axis = 1, inplace = True) 
      simmetric = gpd.overlay(simmetric, i, how='symmetric_difference').fillna(0)
      simmetric.loc[:,'number'] = simmetric.loc[:,'number_1'].add(simmetric.loc[:,'number_2'])
      simmetric.drop(["number_1", "number_2"], axis = 1, inplace = True)     
  final_result = pd.concat([simmetric,intersection])
  final_result.to_file("result.shp")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/tRBts.jpg" rel="nofollow noreferrer">example</a></p>