Skip to content

Commit

Permalink
Merge pull request #466 from PyPSA/fix-build-shapes-unary-union
Browse files Browse the repository at this point in the history
build_shapes: replace unary union from shapely by geopandas equivalent
  • Loading branch information
FabianHofmann authored Feb 7, 2023
2 parents c25f02d + 9f87099 commit 8ebce96
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions scripts/build_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
import pycountry as pyc
from _helpers import configure_logging
from shapely.geometry import MultiPolygon, Polygon
from shapely.ops import unary_union

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -158,8 +157,7 @@ def country_cover(country_shapes, eez_shapes=None):
shapes = country_shapes
if eez_shapes is not None:
shapes = pd.concat([shapes, eez_shapes])

europe_shape = unary_union(shapes)
europe_shape = shapes.unary_union
if isinstance(europe_shape, MultiPolygon):
europe_shape = max(europe_shape, key=attrgetter("area"))
return Polygon(shell=europe_shape.exterior)
Expand Down

0 comments on commit 8ebce96

Please sign in to comment.