diff --git a/pygmt/datasets/tile_map.py b/pygmt/datasets/tile_map.py index e773e1dce38..ed9150b6d61 100644 --- a/pygmt/datasets/tile_map.py +++ b/pygmt/datasets/tile_map.py @@ -3,6 +3,7 @@ :class:`xarray.DataArray`. """ +import contextlib from typing import Literal from packaging.version import Version @@ -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 @@ -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 + CRS.from_epsg(3857) """ if not _HAS_CONTEXTILY: raise ImportError(