Skip to content

Commit

Permalink
Add inline example for grd2xyz (GenericMappingTools#1713)
Browse files Browse the repository at this point in the history
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Meghan Jones <[email protected]>
  • Loading branch information
3 people authored and Josh Sixsmith committed Dec 21, 2022
1 parent 91a1b95 commit d977457
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions pygmt/src/grd2xyz.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ 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``)
Example
-------
>>> 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 pandas DataFrame with the xyz data from an input grid
>>> xyz_dataframe = pygmt.grd2xyz(
... grid=grid, output_type="pandas"
... ) # doctest: +SKIP
>>> xyz_dataframe.head(n=2) # doctest: +SKIP
lon lat elevation
0 10.25 24.75 903.5
1 10.75 24.75 820.0
"""
if output_type not in ["numpy", "pandas", "file"]:
raise GMTInvalidInput(
Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/grdclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def grdclip(grid, **kwargs):
- None if ``outgrid`` is set (grid output will be stored in file set by
``outgrid``)
Examples
--------
Example
-------
>>> 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
Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/grdcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ def grdcut(grid, **kwargs):
- None if ``outgrid`` is set (grid output will be stored in file set by
``outgrid``)
Examples
--------
Example
-------
>>> 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
Expand Down
4 changes: 2 additions & 2 deletions pygmt/src/grdfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def grdfilter(grid, **kwargs):
- None if ``outgrid`` is set (grid output will be stored in file set by
``outgrid``)
Examples
--------
Example
-------
>>> import os
>>> import pygmt
Expand Down

0 comments on commit d977457

Please sign in to comment.