Add inline example for nearneighbor
@@ -12,6 +12,8 @@ from pygmt.helpers import (
)
from pygmt.io import load_dataarray
+__doctest_skip__ = ["nearneighbor"]
+
@fmt_docstring
@use_alias(
@@ -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:
