Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gallery example for grdlandmask #1469

Merged
merged 12 commits into from
Sep 1, 2021
25 changes: 25 additions & 0 deletions examples/gallery/images/grdlandmask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Create 'wet-dry' mask grid
--------------------------
The :meth:`pygmt.grdlandmask` method allows setting
all nodes on land or water to a specified value using
the ``maskvalues`` parameter.
"""

import pygmt

fig = pygmt.Figure()

# Define region of interest
region = [-65, -40, -40, -20]

# Assign a value of 0 for all water masses and a value of 1 for all land masses
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
grid = pygmt.grdlandmask(region=region, spacing="5m", maskvalues=[0, 1], resolution="l")

# Plot clipped grid
fig.basemap(region=region, projection="M12c", frame=True)

fig.grdimage(grid=grid, cmap="lajolla")
fig.colorbar(position="JMR+o0.5c/0c+w8c")
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved

fig.show()