Skip to content

Commit acf48c3

Browse files
committed
load_tile_map: Register the rio accessor by importing rioxarray so the returned raster has CRS
1 parent 3a32169 commit acf48c3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

pygmt/datasets/tile_map.py

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
TileProvider = None
1717
_HAS_CONTEXTILY = False
1818

19+
try:
20+
import rioxarray # rioxarray is needed to register the rio accessor # noqa: F401
21+
22+
_HAS_RIOXARRAY = True
23+
except ImportError:
24+
_HAS_RIOXARRAY = False
25+
1926
import numpy as np
2027
import xarray as xr
2128

@@ -117,6 +124,11 @@ def load_tile_map(
117124
* y (y) float64 ... -7.081e-10 -7.858e+04 ... -1.996e+07 -2.004e+07
118125
* x (x) float64 ... -2.004e+07 -1.996e+07 ... 1.996e+07 2.004e+07
119126
spatial_ref int64 ... 0
127+
>>> # CRS is set only if rioxarray is available
128+
>>> import importlib
129+
>>> if importlib.util.find_spec("rioxarray"):
130+
... raster.rio.crs
131+
CRS.from_epsg(3857)
120132
"""
121133
if not _HAS_CONTEXTILY:
122134
raise ImportError(

0 commit comments

Comments
 (0)