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 grd2xyz #1713

Merged
merged 10 commits into from
Feb 10, 2022
12 changes: 12 additions & 0 deletions pygmt/src/grd2xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs):
- :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is
not set (depends on ``output_type``)

Examples
--------
>>> import pygmt # doctest: +SKIP
>>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30,
>>> # and a y-range of 15 to 25
>>> grid = pygmt.datasets.load_earth_relief(
... resolution="30m", region=[10, 30, 15, 25]
... ) # doctest: +SKIP
>>> # Create a numpy array with the xyz data from an input grid
>>> xyz_array = pygmt.grd2xyz(
willschlitzer marked this conversation as resolved.
Show resolved Hide resolved
... grid=grid, output_type="numpy"
... ) # doctest: +SKIP
seisman marked this conversation as resolved.
Show resolved Hide resolved
"""
seisman marked this conversation as resolved.
Show resolved Hide resolved
if output_type not in ["numpy", "pandas", "file"]:
raise GMTInvalidInput(
Expand Down