Skip to content

Commit

Permalink
Add more methods for rioxarray
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Nov 4, 2024
1 parent 6947ecc commit 544f000
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 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,14 @@ 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
for n in ("to_epsg", "to_proj4"):
with suppress(Exception):
crs = process_crs(getattr(da.rio.crs, n)())
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
1 change: 0 additions & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ nbval = "*"
netcdf4 = "*"
pandas = "*"
pyviz_comms = "*"
rasterio = "!=1.4.2"
rioxarray = "*"
scipy = "*"
shapely = "*"
Expand Down

0 comments on commit 544f000

Please sign in to comment.