From 1c5084f68a147211da66b66b58b5324ad5347341 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:31:29 +1200 Subject: [PATCH 1/2] Replace rio.set_crs with rio.write_crs in load_tile_map function Rioxarray 0.16.0 has deprecated the use of `set_crs` in favour of `write_crs`. Xref https://github.com/corteva/rioxarray/pull/793 --- pygmt/datasets/tile_map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/tile_map.py b/pygmt/datasets/tile_map.py index fec7465bdbf..a8db15414e4 100644 --- a/pygmt/datasets/tile_map.py +++ b/pygmt/datasets/tile_map.py @@ -166,6 +166,6 @@ def load_tile_map( # If rioxarray is installed, set the coordinate reference system if hasattr(dataarray, "rio"): - dataarray = dataarray.rio.set_crs(input_crs="EPSG:3857") + dataarray = dataarray.rio.write_crs(input_crs="EPSG:3857") return dataarray From 52c3ed5cbff6886960f8f2d8fd6b66394f78e992 Mon Sep 17 00:00:00 2001 From: Wei Ji <23487320+weiji14@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:41:12 +1200 Subject: [PATCH 2/2] Add spatial_ref coordinate to load_tile_map's doctest output The `write_crs` command will write an extra grid_mapping attribute to the encoding that shows up in the coordinates. --- pygmt/datasets/tile_map.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/tile_map.py b/pygmt/datasets/tile_map.py index a8db15414e4..6d3bedefc80 100644 --- a/pygmt/datasets/tile_map.py +++ b/pygmt/datasets/tile_map.py @@ -113,9 +113,10 @@ def load_tile_map( Frozen({'band': 3, 'y': 256, 'x': 512}) >>> raster.coords # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE Coordinates: - * band (band) uint8 ... 0 1 2 - * y (y) float64 ... -7.081e-10 -7.858e+04 ... -1.996e+07 ... - * x (x) float64 ... -2.004e+07 -1.996e+07 ... 1.996e+07 2.004e+07 + * band (band) uint8 ... 0 1 2 + * 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 """ if not _HAS_CONTEXTILY: raise ImportError(