Skip to content

Commit 61a6e14

Browse files
authored
Add metadata to earth relief grids (#248)
Add more metadata to the loaded earth relief DataArray and fix issues with stale metadata after slicing the DataArray.
1 parent b2d5b70 commit 61a6e14

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

gmt/datasets/earth_relief.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,17 @@ def load_earth_relief(resolution="60m"):
3737
_is_valid_resolution(resolution)
3838
fname = which("@earth_relief_{}".format(resolution), download="u")
3939
grid = xr.open_dataarray(fname)
40+
# Add some metadata to the grid
41+
grid.name = "elevation"
42+
grid.attrs["long_name"] = "elevation relative to the geoid"
43+
grid.attrs["units"] = "meters"
44+
grid.attrs["vertical_datum"] = "EMG96"
45+
grid.attrs["horizontal_datum"] = "WGS84"
46+
# Remove the actual range because it get's outdated when indexing the grid, which
47+
# causes problems when exporting it to netCDF for usage on the command-line.
48+
grid.attrs.pop("actual_range")
49+
for coord in grid.coords:
50+
grid[coord].attrs.pop("actual_range")
4051
return grid
4152

4253

0 commit comments

Comments
 (0)