Skip to content

Commit d79af32

Browse files
committed
tilemap: Use the new 'crs' parameter to simplify the tilemap function
1 parent e744b00 commit d79af32

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

pygmt/src/tilemap.py

+3-24
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@
99
from pygmt.helpers import build_arg_list, fmt_docstring, kwargs_to_strings, use_alias
1010

1111
try:
12-
import rioxarray # noqa: F401
1312
from xyzservices import TileProvider
14-
15-
_HAS_RIOXARRAY = True
1613
except ImportError:
1714
TileProvider = None
18-
_HAS_RIOXARRAY = False
1915

2016

2117
@fmt_docstring
@@ -111,38 +107,21 @@ def tilemap(
111107
112108
kwargs : dict
113109
Extra keyword arguments to pass to :meth:`pygmt.Figure.grdimage`.
114-
115-
Raises
116-
------
117-
ImportError
118-
If ``rioxarray`` is not installed. Follow
119-
:doc:`install instructions for rioxarray <rioxarray:installation>`, (e.g. via
120-
``python -m pip install rioxarray``) before using this function.
121110
"""
122111
kwargs = self._preprocess(**kwargs)
123112

124-
if not _HAS_RIOXARRAY:
125-
raise ImportError(
126-
"Package `rioxarray` is required to be installed to use this function. "
127-
"Please use `python -m pip install rioxarray` or "
128-
"`mamba install -c conda-forge rioxarray` to install the package."
129-
)
130-
131113
raster = load_tile_map(
132114
region=region,
133115
zoom=zoom,
134116
source=source,
135117
lonlat=lonlat,
118+
crs="OGC:CRS84" if lonlat is True else "EPSG:3857",
136119
wait=wait,
137120
max_retries=max_retries,
138121
zoom_adjust=zoom_adjust,
139122
)
140-
141-
# Reproject raster from Spherical Mercator (EPSG:3857) to lonlat (OGC:CRS84) if
142-
# bounding box region was provided in lonlat
143-
if lonlat and raster.rio.crs == "EPSG:3857":
144-
raster = raster.rio.reproject(dst_crs="OGC:CRS84")
145-
raster.gmt.gtype = 1 # set to geographic type
123+
if lonlat:
124+
raster.gmt.gtype = 1 # Set to geographic type
146125

147126
# Only set region if no_clip is None or False, so that plot is clipped to exact
148127
# bounding box region

0 commit comments

Comments
 (0)