Guest User

Untitled

a guest
Feb 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. df1 = gpd.read_file('shapefile1.shp')
  2. df2 = gpd.read_file('shapefile2.shp')
  3.  
  4. df1['attribute1_of_shp2'] = 0
  5. df1['attribute2_of_shp2'] = 0
  6. for feature in df2.itertuples():
  7. geom = getattr(feature, 'geometry')
  8. attr1 = getattr(feature, 'attribute1')
  9. attr2 = getattr(feature, 'attribute2')
  10. intersection = df1['geometry'].intersection(geom)
  11. df1['RelIntersection'] = intersection.area/df1.area
  12. df1.loc[df['RelIntersection'] > .75, 'attribute1_of_shp2'] = attr1
  13. df1.loc[df['RelIntersection'] > .75, 'attribute2_of_shp2'] = attr2
Add Comment
Please, Sign In to add comment