Skip to content
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
9 changes: 9 additions & 0 deletions pygmt/datasets/tile_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
:class:`xarray.DataArray`.
"""

import contextlib
from typing import Literal

from packaging.version import Version
Expand All @@ -16,6 +17,10 @@
TileProvider = None
_HAS_CONTEXTILY = False

with contextlib.suppress(ImportError):
# rioxarray is needed to register the rio accessor
import rioxarray # noqa: F401

import numpy as np
import xarray as xr

Expand Down Expand Up @@ -117,6 +122,10 @@ def load_tile_map(
* y (y) float64 ... -7.081e-10 -7.858e+04 ... -1.996e+07 -2.004e+07
* x (x) float64 ... -2.004e+07 -1.996e+07 ... 1.996e+07 2.004e+07
spatial_ref int64 ... 0
>>> # CRS is set only if rioxarray is available
>>> if hasattr(raster, "rio"):
... raster.rio.crs
Comment on lines 124 to +127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, we probably don't need the if hasattr(raster, "rio") check, because the spatial_ref int64 ... 0 line above (added in #3321) already means that rioxarray is used (the doctests CI run with rioxarray installed). But I guess it'll be good to mention rioxarray somewhere in the docstring, albeit indirectly.

CRS.from_epsg(3857)
"""
if not _HAS_CONTEXTILY:
raise ImportError(
Expand Down