Skip to content

Commit

Permalink
update shapely usage for version 1.8 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
aperrin66 committed Dec 15, 2023
1 parent bda783d commit 80ae872
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions geospaas_harvesting/providers/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import dateutil.parser
import netCDF4
import numpy as np
import shapely
import shapely.wkt
from dateutil.tz import tzutc
from shapely.geometry import MultiPoint

Expand Down Expand Up @@ -118,8 +118,8 @@ def get_normalized_attributes(self, dataset_info, **kwargs):
# Find coverage to set number of points in the geolocation
if nansat_object.vrt.dataset.GetGCPs():
nansat_object.reproject_gcps()
normalized_attributes['location_geometry'] = shapely.set_srid(shapely.from_wkt(
nansat_object.get_border_wkt(n_points=n_points)), 4326)
normalized_attributes['location_geometry'] = shapely.wkt.loads(
nansat_object.get_border_wkt(n_points=n_points))

json_dumped_dataset_parameters = n_metadata.get('dataset_parameters', None)
if json_dumped_dataset_parameters:
Expand Down Expand Up @@ -185,7 +185,7 @@ def _get_geometry_wkt(self, dataset):
flags=['buffered']))
else:
raise ValueError("Could not determine the spatial coverage")
geometry = shapely.set_srid(MultiPoint(points).convex_hull, 4326)
geometry = MultiPoint(points).convex_hull
return geometry.wkt

def _get_raw_attributes(self, dataset_path):
Expand Down
6 changes: 3 additions & 3 deletions tests/providers/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime, timezone

import numpy as np
import shapely
import shapely.wkt
from geospaas.catalog.managers import (FILE_SERVICE_NAME,
LOCAL_FILE_SERVICE,
DAP_SERVICE_NAME,
Expand Down Expand Up @@ -121,8 +121,8 @@ def test_normalize_netcdf_attributes_with_nansat(self):
self.assertEqual(normalized_attributes['platform']['Category'], 'Models/Analyses')
self.assertEqual(normalized_attributes['platform']['Series_Entity'], '')

expected_geometry = shapely.set_srid(shapely.from_wkt(
'POLYGON((24.88 68.08,22.46 68.71,19.96 69.31,17.39 69.87,24.88 68.08))'), 4326)
expected_geometry = shapely.wkt.loads(
'POLYGON((24.88 68.08,22.46 68.71,19.96 69.31,17.39 69.87,24.88 68.08))')

# This fails, which is why string representations are compared. Any explanation is welcome.
# self.assertTrue(normalized_attributes['location_geometry'].equals(expected_geometry))
Expand Down

0 comments on commit 80ae872

Please sign in to comment.