From c7aaa12c3e2563c94693ca562f099431e854a28c Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 4 Nov 2024 19:47:00 +0800 Subject: [PATCH] pygmt.datasets.load_tile_map: Fix the rio.crs output for rasterio 1.4.2 (#3576) --- pygmt/datasets/tile_map.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/tile_map.py b/pygmt/datasets/tile_map.py index 15331e256bb..c3322c39c36 100644 --- a/pygmt/datasets/tile_map.py +++ b/pygmt/datasets/tile_map.py @@ -126,23 +126,25 @@ def load_tile_map( >>> # CRS is set only if rioxarray is available >>> if hasattr(raster, "rio"): ... raster.rio.crs - CRS.from_epsg(3857) + CRS.from_wkt(...) """ if not _HAS_CONTEXTILY: - raise ImportError( + msg = ( "Package `contextily` is required to be installed to use this function. " "Please use `python -m pip install contextily` or " "`mamba install -c conda-forge contextily` to install the package." ) + raise ImportError(msg) contextily_kwargs = {} if zoom_adjust is not None: contextily_kwargs["zoom_adjust"] = zoom_adjust if Version(contextily.__version__) < Version("1.5.0"): - raise TypeError( + msg = ( "The `zoom_adjust` parameter requires `contextily>=1.5.0` to work. " "Please upgrade contextily, or manually set the `zoom` level instead." ) + raise TypeError(msg) west, east, south, north = region image, extent = contextily.bounds2img(