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 inline example for grdtrack #1725

Merged
merged 7 commits into from
Mar 12, 2022
Merged
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
18 changes: 18 additions & 0 deletions pygmt/src/grdtrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
use_alias,
)

__doctest_skip__ = ["grdtrack"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -264,6 +266,22 @@ def grdtrack(points, grid, newcolname=None, outfile=None, **kwargs):
``outfile`` is not set
- None if ``outfile`` is set (track output will be stored in file set
by ``outfile``)

Example
-------
>>> import pygmt
>>> # Load a grid of @earth_relief_30m data, with an x-range of -118 to
>>> # -107, and a y-range of -49 to -42
>>> grid = pygmt.datasets.load_earth_relief(
... resolution="30m", region=[-118, -107, -49, -42]
... )
>>> # Load a pandas dataframe with ocean ridge points
>>> points = pygmt.datasets.load_sample_data(name="ocean_ridge_points")
>>> # Create a pandas dataframe from an input grid and set of points
>>> # The output dataframe adds a column named "bathymetry"
>>> output_dataframe = pygmt.grdtrack(
... points=points, grid=grid, newcolname="bathymetry"
... )
"""
if hasattr(points, "columns") and newcolname is None:
raise GMTInvalidInput("Please pass in a str to 'newcolname'")
Expand Down