-
Notifications
You must be signed in to change notification settings - Fork 228
Add gallery example for grdclip #1396
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
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
dc5cf3e
Add gallery example for grdclip
michaelgrund a6c4e62
[format-command] fixes
actions-bot 03a1984
add docstring
michaelgrund 6f9f84a
update docstring
michaelgrund 92d78db
Merge branch 'master' into gallery-grdclip
michaelgrund d5c9037
Update examples/gallery/images/grdclip.py
michaelgrund 6ad00e8
updates
michaelgrund c955e69
Merge branch 'master' into gallery-grdclip
michaelgrund ba5c105
updates based on code review
michaelgrund a1401bd
Update examples/gallery/images/grdclip.py
michaelgrund da13edb
updates
michaelgrund e9652de
Merge branch 'master' into gallery-grdclip
seisman 40c65e2
Merge branch 'master' into gallery-grdclip
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
Clipping grid values | ||
-------------------- | ||
The :meth:`pygmt.grdclip` method allows to clip defined ranges of grid values. | ||
In the example shown below we set all elevation values (grid points) smaller | ||
than 0 m (in general the bathymetric part of the grid) to a common value of | ||
-2000 m via the ``below`` parameter. | ||
""" | ||
|
||
import pygmt | ||
|
||
fig = pygmt.Figure() | ||
|
||
# Define region of interest around Iceland | ||
region = [-28, -10, 62, 68] | ||
|
||
# Load sample grid (3 arc minute global relief) in target area | ||
grid = pygmt.datasets.load_earth_relief(resolution="03m", region=region) | ||
|
||
# Plot original grid | ||
fig.basemap(region=region, projection="M12c", frame=["f", '+t"original grid"']) | ||
fig.grdimage(grid=grid, cmap="oleron") | ||
|
||
# Shift plot origin for second map 12.5 cm in x direction | ||
fig.shift_origin(xshift="12.5c") | ||
|
||
# Set all grid points < 0 m to a value of -2000 m. | ||
grid = pygmt.grdclip(grid, below=[0, -2000]) | ||
|
||
# Plot clipped grid | ||
fig.basemap(region=region, projection="M12c", frame=["f", '+t"clipped grid"']) | ||
fig.grdimage(grid=grid) | ||
fig.colorbar(frame=["x+lElevation", "y+lm"], position="JMR+o0.5c/0c+w8c") | ||
|
||
fig.show() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.