Skip to content

Commit

Permalink
Replace rio.set_crs with rio.write_crs in load_tile_map function (#3321)
Browse files Browse the repository at this point in the history
* 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 corteva/rioxarray#793

* 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.
  • Loading branch information
weiji14 committed Jul 9, 2024
1 parent 9c13eb0 commit 3a32169
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pygmt/datasets/tile_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -166,6 +167,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

0 comments on commit 3a32169

Please sign in to comment.