From efedfa945b0ed4d0bcb4980210015edf1ec3f374 Mon Sep 17 00:00:00 2001 From: Fabian Date: Tue, 7 Feb 2023 14:07:44 +0100 Subject: [PATCH 1/2] build_shapes: replace unary union from shapely by geopandas equivalent --- scripts/build_shapes.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/build_shapes.py b/scripts/build_shapes.py index cda27963..8be1ec0e 100644 --- a/scripts/build_shapes.py +++ b/scripts/build_shapes.py @@ -80,7 +80,6 @@ import pandas as pd 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__) @@ -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) @@ -265,6 +263,7 @@ if __name__ == "__main__": ) offshore_shapes.reset_index().to_file(snakemake.output.offshore_shapes) + europe_shape = gpd.GeoDataFrame( geometry=[country_cover(country_shapes, offshore_shapes.geometry)] ) From 9f87099dbbb0d2519235cc19327dbb198776e040 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 13:12:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/build_shapes.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build_shapes.py b/scripts/build_shapes.py index 8be1ec0e..42118b7d 100644 --- a/scripts/build_shapes.py +++ b/scripts/build_shapes.py @@ -263,7 +263,6 @@ if __name__ == "__main__": ) offshore_shapes.reset_index().to_file(snakemake.output.offshore_shapes) - europe_shape = gpd.GeoDataFrame( geometry=[country_cover(country_shapes, offshore_shapes.geometry)] )