From 7ad2d85e8abf1b06e0570457382bd064ee062972 Mon Sep 17 00:00:00 2001 From: Alexey Pechnikov Date: Sat, 30 Nov 2024 15:44:45 +0700 Subject: [PATCH] Replace unary_union by union_all() --- pygmtsar/pygmtsar/Stack_align.py | 4 ++-- pygmtsar/pygmtsar/Stack_reframe.py | 4 ++-- pygmtsar/pygmtsar/datagrid.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pygmtsar/pygmtsar/Stack_align.py b/pygmtsar/pygmtsar/Stack_align.py index bb8d5441..47633d88 100644 --- a/pygmtsar/pygmtsar/Stack_align.py +++ b/pygmtsar/pygmtsar/Stack_align.py @@ -359,7 +359,7 @@ def compute_align(self, geometry='auto', dates=None, n_jobs=-1, degrees=12.0/360 from tqdm.auto import tqdm import joblib import warnings - # supress warnings about unary_union future behaviour to replace None by empty collection + # supress warnings about unary_union/union_all() future behaviour to replace None by empty collection warnings.filterwarnings('ignore') if joblib_aligning_backend is not None: @@ -396,7 +396,7 @@ def compute_align(self, geometry='auto', dates=None, n_jobs=-1, degrees=12.0/360 'noisepath': lambda p: list(p), 'calibpath': lambda p: list(p), 'orbitpath': 'min', - 'geometry': lambda g: g.unary_union + 'geometry': lambda g: g.union_all() }) # update the main object for the merged subswaths self.df = gpd.GeoDataFrame(df) diff --git a/pygmtsar/pygmtsar/Stack_reframe.py b/pygmtsar/pygmtsar/Stack_reframe.py index efb4c6a9..bcd430c8 100644 --- a/pygmtsar/pygmtsar/Stack_reframe.py +++ b/pygmtsar/pygmtsar/Stack_reframe.py @@ -52,7 +52,7 @@ def _reframe_subswath(self, subswath, date, geometry, debug=False): # define line covering some bursts to crop them if isinstance(geometry, (gpd.GeoDataFrame, gpd.GeoSeries)): # it does not work with numpy 2.0.0 for geometry.minimum_rotated_rectangle - geometry = geometry.unary_union + geometry = geometry.union_all() assert not geometry is None, f'ERROR: subswath {subswath} is not covered, you need to exclude it.' # convert to polygon when possible @@ -311,7 +311,7 @@ def compute_reframe(self, geometry=None, n_jobs=-1, queue=16, caption='Reframing dates = self.df.index.unique().values subswaths = self.get_subswaths() # approximate subswath geometries from GCP - geometries = {subswath: self.df[self.df.subswath==subswath].geometry.unary_union for subswath in subswaths} + geometries = {subswath: self.df[self.df.subswath==subswath].geometry.union_all() for subswath in subswaths} records = [] # Applying iterative processing to prevent Dask scheduler deadlocks. diff --git a/pygmtsar/pygmtsar/datagrid.py b/pygmtsar/pygmtsar/datagrid.py index e417f4a3..3fba18fe 100644 --- a/pygmtsar/pygmtsar/datagrid.py +++ b/pygmtsar/pygmtsar/datagrid.py @@ -260,7 +260,7 @@ def get_bounds(geometry): elif isinstance(geometry, gpd.GeoDataFrame): bounds = geometry.dissolve().envelope.item().bounds elif isinstance(geometry, gpd.GeoSeries): - bounds = geometry.unary_union.envelope.bounds + bounds = geometry.union_all().envelope.bounds elif isinstance(geometry, tuple): # geometry is already bounds bounds = geometry