Skip to content

Commit dc5cf3e

Browse files
authored
Add gallery example for grdclip
Since noone worked on this issue during the scipy-sprint here's a gallery example adressing #1384.
1 parent 945bbc5 commit dc5cf3e

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

examples/gallery/images/grdclip.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pygmt
2+
3+
fig = pygmt.Figure()
4+
5+
# Load sample grid and use area around the Hawaiian Islands
6+
grid = pygmt.datasets.load_earth_relief(resolution="01m", region = [-162, -153, 18, 23])
7+
8+
# Plot original grid
9+
fig.basemap(region = [-162, -153, 18, 23], projection="M12c", frame=["f", '+t"original grid"'])
10+
fig.grdimage(grid=grid, cmap="oleron")
11+
12+
fig.shift_origin(yshift = "-9c")
13+
14+
# Set all grid points < 0 to a value of -2000.
15+
grid = pygmt.grdclip(grid, below = [0, -2000])
16+
17+
# Plot clipped grid
18+
fig.basemap(region = [-162, -153, 18, 23], projection="M12c", frame=["f", '+t"clipped grid"'])
19+
fig.grdimage(grid=grid)
20+
fig.colorbar(frame=["x+lElevation", "y+lm"])
21+
22+
fig.show()

0 commit comments

Comments
 (0)