Skip to content

Commit

Permalink
Add gallery example for grdclip
Browse files Browse the repository at this point in the history
Since noone worked on this issue during the scipy-sprint here's a gallery example adressing #1384.
  • Loading branch information
michaelgrund authored Jul 26, 2021
1 parent 945bbc5 commit dc5cf3e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions examples/gallery/images/grdclip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import pygmt

fig = pygmt.Figure()

# Load sample grid and use area around the Hawaiian Islands
grid = pygmt.datasets.load_earth_relief(resolution="01m", region = [-162, -153, 18, 23])

# Plot original grid
fig.basemap(region = [-162, -153, 18, 23], projection="M12c", frame=["f", '+t"original grid"'])
fig.grdimage(grid=grid, cmap="oleron")

fig.shift_origin(yshift = "-9c")

# Set all grid points < 0 to a value of -2000.
grid = pygmt.grdclip(grid, below = [0, -2000])

# Plot clipped grid
fig.basemap(region = [-162, -153, 18, 23], projection="M12c", frame=["f", '+t"clipped grid"'])
fig.grdimage(grid=grid)
fig.colorbar(frame=["x+lElevation", "y+lm"])

fig.show()

0 comments on commit dc5cf3e

Please sign in to comment.