Skip to content

Commit 2c04717

Browse files
willschlitzerweiji14Meghan Jones
authored
Add inline example for grd2xyz (#1713)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Meghan Jones <[email protected]>
1 parent f17ddb3 commit 2c04717

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

pygmt/src/grd2xyz.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,22 @@ def grd2xyz(grid, output_type="pandas", outfile=None, **kwargs):
126126
- :class:`pandas.DataFrame` or :class:`numpy.ndarray` if ``outfile`` is
127127
not set (depends on ``output_type``)
128128
129+
Example
130+
-------
131+
>>> import pygmt # doctest: +SKIP
132+
>>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30,
133+
>>> # and a y-range of 15 to 25
134+
>>> grid = pygmt.datasets.load_earth_relief(
135+
... resolution="30m", region=[10, 30, 15, 25]
136+
... ) # doctest: +SKIP
137+
>>> # Create a pandas DataFrame with the xyz data from an input grid
138+
>>> xyz_dataframe = pygmt.grd2xyz(
139+
... grid=grid, output_type="pandas"
140+
... ) # doctest: +SKIP
141+
>>> xyz_dataframe.head(n=2) # doctest: +SKIP
142+
lon lat elevation
143+
0 10.25 24.75 903.5
144+
1 10.75 24.75 820.0
129145
"""
130146
if output_type not in ["numpy", "pandas", "file"]:
131147
raise GMTInvalidInput(

pygmt/src/grdclip.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def grdclip(grid, **kwargs):
7878
- None if ``outgrid`` is set (grid output will be stored in file set by
7979
``outgrid``)
8080
81-
Examples
82-
--------
81+
Example
82+
-------
8383
>>> import pygmt # doctest: +SKIP
8484
>>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30,
8585
>>> # and a y-range of 15 to 25

pygmt/src/grdcut.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ def grdcut(grid, **kwargs):
8888
- None if ``outgrid`` is set (grid output will be stored in file set by
8989
``outgrid``)
9090
91-
Examples
92-
--------
91+
Example
92+
-------
9393
>>> import pygmt # doctest: +SKIP
9494
>>> # Load a grid of @earth_relief_30m data, with an x-range of 10 to 30,
9595
>>> # and a y-range of 15 to 25

pygmt/src/grdfilter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ def grdfilter(grid, **kwargs):
119119
- None if ``outgrid`` is set (grid output will be stored in file set by
120120
``outgrid``)
121121
122-
Examples
123-
--------
122+
Example
123+
-------
124124
>>> import os
125125
>>> import pygmt
126126

0 commit comments

Comments
 (0)