Skip to content

Commit

Permalink
Add inline example for sphdistance (#1916)
Browse files Browse the repository at this point in the history
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Dongdong Tian <[email protected]>
  • Loading branch information
3 people authored May 6, 2022
1 parent 3eae627 commit 951d30a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pygmt/src/sphdistance.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
)
from pygmt.io import load_dataarray

__doctest_skip__ = ["sphdistance"]


@fmt_docstring
@use_alias(
Expand Down Expand Up @@ -99,6 +101,19 @@ def sphdistance(data=None, x=None, y=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 numpy as np
>>> import pygmt
>>> # Create an array of longitude/latitude coordinates
>>> coords_list = [[85.5, 22.3], [82.3, 22.6], [85.8, 22.4], [86.5, 23.3]]
>>> coords_array = np.array(coords_list)
>>> # Perform a calculation of the distance to
>>> # each point from Voronoi polygons
>>> grid = pygmt.sphdistance(
... data=coords_array, spacing=[1, 2], region=[82, 87, 22, 24]
... )
"""
if kwargs.get("I") is None or kwargs.get("R") is None:
raise GMTInvalidInput("Both 'region' and 'spacing' must be specified.")
Expand Down

0 comments on commit 951d30a

Please sign in to comment.