Skip to content

Commit

Permalink
Add Shapely 2 support (#603)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jan 4, 2023
1 parent 13f4303 commit 0a099b5
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
DISPLAY: ":99.0"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
USE_PYGEOS: '0'
steps:
- uses: pyviz-dev/holoviz_tasks/install@v0.1a9
with:
Expand Down
5 changes: 4 additions & 1 deletion geoviews/data/iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ def concat_dim(cls, datasets, dim, vdims):
Concatenates datasets along one dimension
"""
import iris
from iris.experimental.equalise_cubes import equalise_attributes
try:
from iris.util import equalise_attributes
except ImportError:
from iris.experimental.equalise_cubes import equalise_attributes

cubes = []
for c, cube in datasets.items():
Expand Down
2 changes: 1 addition & 1 deletion geoviews/element/geo.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def __init__(self, data, kdims=None, vdims=None, **params):
super(Feature, self).__init__(data, kdims=kdims, vdims=vdims, **params)

def __call__(self, *args, **kwargs):
return self.opts(*args, **kwargs)
return self.clone().opts(*args, **kwargs)

def geoms(self, scale=None, bounds=None, as_element=True):
"""
Expand Down
2 changes: 1 addition & 1 deletion geoviews/operation/projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _process_element(self, element):
continue
finally:
logger.setLevel(prev)
if proj_geom.geom_type == 'GeometryCollection' and len(proj_geom) == 0:
if proj_geom.geom_type in ['GeometryCollection', 'MultiPolygon'] and len(proj_geom.geoms) == 0:
continue
data = dict(path, geometry=proj_geom)
if 'holes' in data:
Expand Down
4 changes: 3 additions & 1 deletion geoviews/operation/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from shapely.geometry import Polygon
from shapely.strtree import STRtree

from ..util import polygons_to_geom_dicts, path_to_geom_dicts
from ..util import polygons_to_geom_dicts, path_to_geom_dicts, shapely_v2



def find_geom(geom, geoms):
Expand Down Expand Up @@ -165,6 +166,7 @@ def _process(self, element, key=None):
# Query RTree, then cull and simplify polygons
new_geoms, gdict = [], {}
for g in tree.query(bounds):
g = tree.geometries[g] if shapely_v2 else g
garea = area_cache.get(id(g))
if garea is None:
is_poly = 'Polygon' in g.geom_type
Expand Down
1 change: 1 addition & 0 deletions geoviews/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@


shapely_version = Version(shapely.__version__)
shapely_v2 = shapely_version >= Version("2")


def wrap_lons(lons, base, period):
Expand Down
8 changes: 6 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ nbsmoke_skip_run = .*Homepage\.ipynb$
.*gallery/.*/xarray_quadmesh\.ipynb$
.*gallery/.*/katrina_track\.ipynb$
filterwarnings =
ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:bokeh
ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:cupy
; 2023-01: https://github.com/bokeh/bokeh/pull/12690
ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:bokeh
; 2023-01: https://github.com/cupy/cupy/pull/7245
ignore:`.+?` is a deprecated alias for `.+?`.:DeprecationWarning:cupy
; 2023-01: https://github.com/SciTools/cartopy/issues/2113
ignore:The 'geom_factory' function is deprecated in Shapely 2:DeprecationWarning:cartopy.crs

[flake8]
include = *.py
Expand Down

0 comments on commit 0a099b5

Please sign in to comment.