Skip to content

Commit

Permalink
Update geospatial_utilities.py
Browse files Browse the repository at this point in the history
  • Loading branch information
barneydobson committed Mar 26, 2024
1 parent e7feb7a commit edb8b64
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions swmmanywhere/geospatial_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from scipy.interpolate import RegularGridInterpolator
from shapely import geometry as sgeom
from shapely import ops as sops
from shapely.errors import GEOSException
from shapely.strtree import STRtree
from tqdm import tqdm

Expand Down Expand Up @@ -655,8 +656,13 @@ def derive_rc(polys_gdf: gpd.GeoDataFrame,
building_footprints[['geometry']],
how='union')
result = gpd.overlay(polys_gdf, result)

dissolved_result = result.dissolve(by='id').reset_index()
try:
dissolved_result = result.dissolve(by='id').reset_index()
except GEOSException:
# Temporary fix for bug:
# https://github.com/ImperialCollegeLondon/SWMManywhere/issues/115
result['geometry'] = result['geometry'].simplify(0.1)
dissolved_result = result.dissolve(by='id').reset_index()
dissolved_result['impervious_area'] = dissolved_result.geometry.area
polys_gdf = pd.merge(polys_gdf,
dissolved_result[['id','impervious_area']],
Expand Down

0 comments on commit edb8b64

Please sign in to comment.