Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df1 = gpd.read_file('shapefile1.shp')
- df2 = gpd.read_file('shapefile2.shp')
- df1['attribute1_of_shp2'] = 0
- df1['attribute2_of_shp2'] = 0
- for feature in df2.itertuples():
- geom = getattr(feature, 'geometry')
- attr1 = getattr(feature, 'attribute1')
- attr2 = getattr(feature, 'attribute2')
- intersection = df1['geometry'].intersection(geom)
- df1['RelIntersection'] = intersection.area/df1.area
- df1.loc[df['RelIntersection'] > .75, 'attribute1_of_shp2'] = attr1
- df1.loc[df['RelIntersection'] > .75, 'attribute2_of_shp2'] = attr2
Add Comment
Please, Sign In to add comment