Skip to content

Commit

Permalink
Add inline example for nearneighbor (#1919)
Browse files Browse the repository at this point in the history
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
  • Loading branch information
willschlitzer and seisman authored May 11, 2022
1 parent 951d30a commit d4caab4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pygmt/src/nearneighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
)
from pygmt.io import load_dataarray

__doctest_skip__ = ["nearneighbor"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -131,6 +133,19 @@ def nearneighbor(data=None, x=None, y=None, z=None, **kwargs):
- :class:`xarray.DataArray`: if ``outgrid`` is not set
- None if ``outgrid`` is set (grid output will be stored in file set by
``outgrid``)
Example
-------
>>> import pygmt
>>> # Load a sample dataset of bathymetric x, y, and z values
>>> data = pygmt.datasets.load_sample_data(name="bathymetry")
>>> # Create a new grid with 5 arc-minute spacing in the designated region
>>> # Set search_radius to only consider points within 10 arc-minute of a node
>>> output = pygmt.nearneighbor(
... data=data,
... spacing="5m",
... region=[245, 255, 20, 30],
... search_radius="10m",
... )
"""
with GMTTempFile(suffix=".nc") as tmpfile:
with Session() as lib:
Expand Down

0 comments on commit d4caab4

Please sign in to comment.