Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compat: rasterio 1.4.2 #763

Merged
merged 3 commits into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions geoviews/util.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from contextlib import suppress

import numpy as np
import shapely
import shapely.geometry as sgeom
Expand Down Expand Up @@ -652,9 +654,16 @@ def from_xarray(da, crs=None, apply_transform=False, nan_nodata=False, **kwargs)
'defaulting to non-geographic element.')
elif hasattr(da, 'rio') and da.rio.crs is not None:
# rioxarray.open_rasterio
try:
kwargs['crs'] = process_crs(da.rio.crs.to_proj4())
except Exception:
crs = None
# to handle rasterio 1.4.1 vs 1.4.2 differences
# https://github.com/holoviz/geoviews/pull/763
for method_name in ("to_epsg", "to_proj4"):
with suppress(Exception):
crs = process_crs(getattr(da.rio.crs, method_name)())
break
if crs:
kwargs['crs'] = crs
else:
warn(f'Could not decode projection from crs string {da.rio.crs}, '
'defaulting to non-geographic element.')

Expand Down
Loading