Skip to content

Commit

Permalink
Add inline example for grdtrack (#1725)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
  • Loading branch information
4 people committed Mar 12, 2022
1 parent fc352ca commit d85bfdf
Showing 1 changed file with 18 additions and 0 deletions.
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

0 comments on commit d85bfdf

Please sign in to comment.