Skip to content

Commit 951d30a

Browse files
willschlitzerweiji14seisman
authored
Add inline example for sphdistance (#1916)
Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
1 parent 3eae627 commit 951d30a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pygmt/src/sphdistance.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
)
1414
from pygmt.io import load_dataarray
1515

16+
__doctest_skip__ = ["sphdistance"]
17+
1618

1719
@fmt_docstring
1820
@use_alias(
@@ -99,6 +101,19 @@ def sphdistance(data=None, x=None, y=None, **kwargs):
99101
- :class:`xarray.DataArray` if ``outgrid`` is not set
100102
- None if ``outgrid`` is set (grid output will be stored in file set by
101103
``outgrid``)
104+
105+
Example
106+
-------
107+
>>> import numpy as np
108+
>>> import pygmt
109+
>>> # Create an array of longitude/latitude coordinates
110+
>>> coords_list = [[85.5, 22.3], [82.3, 22.6], [85.8, 22.4], [86.5, 23.3]]
111+
>>> coords_array = np.array(coords_list)
112+
>>> # Perform a calculation of the distance to
113+
>>> # each point from Voronoi polygons
114+
>>> grid = pygmt.sphdistance(
115+
... data=coords_array, spacing=[1, 2], region=[82, 87, 22, 24]
116+
... )
102117
"""
103118
if kwargs.get("I") is None or kwargs.get("R") is None:
104119
raise GMTInvalidInput("Both 'region' and 'spacing' must be specified.")

0 commit comments

Comments
 (0)