seagrid.utils.lldist#

Great-circle distances (2.x interface). All distances are in metres.

New code uses seagrid.grids.metrics.great_circle().

Module Attributes

earth_radius

Mean Earth radius in metres.

Functions

distance_matrix(lonvec, latvec)

Return the matrix of distances between all pairs of points.

ll2dist(lon, lat)

Return the distance between row 0 and row 1 of 2-D coordinates, per column.

ll2dist2vec(lonvec1, latvec1, lonvec2, latvec2)

Return the distance between corresponding points of two sets.

lldist(lon, lat)

Return the distance from each point of a track to the previous one.

spherical_dist(pos1, pos2[, r])

Return the distance between positions given as [..., (lat, lon)].

seagrid.utils.lldist.distance_matrix(lonvec, latvec)[source]#

Return the matrix of distances between all pairs of points.

Parameters:
  • lonvec (ArrayLike)

  • latvec (ArrayLike)

Return type:

ndarray[tuple[Any, …], dtype[float64]]

seagrid.utils.lldist.earth_radius = 6371000.0#

Mean Earth radius in metres.

seagrid.utils.lldist.ll2dist(lon, lat)[source]#

Return the distance between row 0 and row 1 of 2-D coordinates, per column.

Parameters:
  • lon (ArrayLike)

  • lat (ArrayLike)

Return type:

ndarray[tuple[Any, …], dtype[float64]]

seagrid.utils.lldist.ll2dist2vec(lonvec1, latvec1, lonvec2, latvec2)[source]#

Return the distance between corresponding points of two sets.

Parameters:
  • lonvec1 (ArrayLike)

  • latvec1 (ArrayLike)

  • lonvec2 (ArrayLike)

  • latvec2 (ArrayLike)

Return type:

ndarray[tuple[Any, …], dtype[float64]]

seagrid.utils.lldist.lldist(lon, lat)[source]#

Return the distance from each point of a track to the previous one.

Parameters:
  • lon (array_like) – 1-D track positions in decimal degrees.

  • lat (array_like) – 1-D track positions in decimal degrees.

Returns:

numpy.ndarray – Same length as the track; the first element is 0.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

seagrid.utils.lldist.spherical_dist(pos1, pos2, r=EARTH_RADIUS)[source]#

Return the distance between positions given as [..., (lat, lon)].

Parameters:
  • pos1 (array_like) – Latitude and longitude in decimal degrees along the last axis.

  • pos2 (array_like) – Latitude and longitude in decimal degrees along the last axis.

  • r (float, optional) – Sphere radius in metres. Default earth_radius. (In 2.x the default was 3958.75 but was ignored.)

Returns:

numpy.ndarray

Return type:

ndarray[tuple[Any, …], dtype[float64]]