Skip to content

Commit d4caab4

Browse files
Add inline example for nearneighbor (#1919)
Co-authored-by: Dongdong Tian <[email protected]>
1 parent 951d30a commit d4caab4

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pygmt/src/nearneighbor.py

+15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
)
1313
from pygmt.io import load_dataarray
1414

15+
__doctest_skip__ = ["nearneighbor"]
16+
1517

1618
@fmt_docstring
1719
@use_alias(
@@ -131,6 +133,19 @@ def nearneighbor(data=None, x=None, y=None, z=None, **kwargs):
131133
- :class:`xarray.DataArray`: if ``outgrid`` is not set
132134
- None if ``outgrid`` is set (grid output will be stored in file set by
133135
``outgrid``)
136+
Example
137+
-------
138+
>>> import pygmt
139+
>>> # Load a sample dataset of bathymetric x, y, and z values
140+
>>> data = pygmt.datasets.load_sample_data(name="bathymetry")
141+
>>> # Create a new grid with 5 arc-minute spacing in the designated region
142+
>>> # Set search_radius to only consider points within 10 arc-minute of a node
143+
>>> output = pygmt.nearneighbor(
144+
... data=data,
145+
... spacing="5m",
146+
... region=[245, 255, 20, 30],
147+
... search_radius="10m",
148+
... )
134149
"""
135150
with GMTTempFile(suffix=".nc") as tmpfile:
136151
with Session() as lib:

0 commit comments

Comments
 (0)