Add metadata to earth relief grids
Add more metadata to the loaded earth relief DataArray and fix issues with stale metadata after slicing the DataArray.
@@ -37,6 +37,17 @@ def load_earth_relief(resolution="60m"):
_is_valid_resolution(resolution)
fname = which("@earth_relief_{}".format(resolution), download="u")
grid = xr.open_dataarray(fname)
+ # Add some metadata to the grid
+ grid.name = "elevation"
+ grid.attrs["long_name"] = "elevation relative to the geoid"
+ grid.attrs["units"] = "meters"
+ grid.attrs["vertical_datum"] = "EMG96"
+ grid.attrs["horizontal_datum"] = "WGS84"
+ # Remove the actual range because it get's outdated when indexing the grid, which
+ # causes problems when exporting it to netCDF for usage on the command-line.
+ grid.attrs.pop("actual_range")
+ for coord in grid.coords:
+ grid[coord].attrs.pop("actual_range")
return grid
