Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pygmt/datasets/earth_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,7 @@ def load_earth_mask(resolution="01d", region=None, registration=None):
region=region,
registration=registration,
)
return grid.astype("int8")
# `return grid.astype("int8")` doesn't work because grid encoding is lost.
# See https://github.com/GenericMappingTools/pygmt/issues/2629.
grid.data = grid.data.astype("int8")
return grid
3 changes: 3 additions & 0 deletions pygmt/tests/test_datasets_earth_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def test_earth_mask_01d():
assert data.attrs["horizontal_datum"] == "WGS84"
assert data.shape == (181, 361)
assert data.gmt.registration == 0
assert data.gmt.gtype == 1
assert data.dtype == "int8"
npt.assert_allclose(data.lat, np.arange(-90, 91, 1))
npt.assert_allclose(data.lon, np.arange(-180, 181, 1))
Expand All @@ -52,6 +53,8 @@ def test_earth_mask_01d_with_region():
data = load_earth_mask(resolution="01d", region=[-7, 4, 13, 19])
assert data.shape == (7, 12)
assert data.gmt.registration == 0
assert data.gmt.gtype == 1
assert data.dtype == "int8"
npt.assert_allclose(data.lat, np.arange(13, 20, 1))
npt.assert_allclose(data.lon, np.arange(-7, 5, 1))
npt.assert_allclose(data[1, 5], 1)