Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

pastax.geo

Geographic utilities: unit conversions and Haversine distance.

EARTH_RADIUS

pastax.geo.EARTH_RADIUS: float = 6371008.8

Mean Earth radius in metres (IUGG 2015 mean radius).

haversine

pastax.geo.haversine(y1, y2)

Great-circle distance between [lat, lon] points.

Uses the spherical haversine formula with EARTH_RADIUS as the sphere radius RR:

a=sin2 ⁣(Δφ2)+cosφ1cosφ2sin2 ⁣(Δλ2)a = \sin^2\!\left(\tfrac{\Delta\varphi}{2}\right) + \cos\varphi_1 \cos\varphi_2 \sin^2\!\left(\tfrac{\Delta\lambda}{2}\right)
d=2Rarcsin ⁣ad = 2 R \arcsin\!\sqrt{a}

where φ\varphi is latitude and λ\lambda is longitude (in radians). The last axis of each input must have size 2 (lat, lon); leading axes broadcast under standard NumPy/JAX rules.

Parameters
  • y1 (Float[jaxlib._jax.Array, '... 2'])First point(s) [lat, lon] in degrees, shape (..., 2).

  • y2 (Float[jaxlib._jax.Array, '... 2'])Second point(s) [lat, lon] in degrees, shape (..., 2).

Returns

Great-circle distance in metres, with shape matching the broadcast of the leading axes of y1 and y2.

Return type

Float[jaxlib._jax.Array, ]

meters_to_degrees

pastax.geo.meters_to_degrees(disp_m, lat_deg)

Convert a [north, east] displacement in metres to [dlat, dlon] in degrees.

Uses a flat-Earth approximation around lat_deg: the meridional component is converted via EARTH_RADIUS; the zonal component is additionally divided by cos(lat)\cos(\mathrm{lat}) to account for shrinking longitude circles toward the poles.

Parameters
  • disp_m (Float[jaxlib._jax.Array, '... 2'])Displacement(s) [north, east] in metres. The last axis must have size 2; leading axes are passed through unchanged.

  • lat_deg (Float[jaxlib._jax.Array, ''])Reference latitude in degrees, used for the longitude scaling.

Returns

Same shape as disp_m, but expressed as [dlat, dlon] in degrees.

Return type

Float[jaxlib._jax.Array, 2’]

degrees_to_meters

pastax.geo.degrees_to_meters(disp_deg, lat_deg)

Convert a [dlat, dlon] displacement in degrees to [north, east] in metres.

Inverse of meters_to_degrees(). Uses a flat-Earth approximation around lat_deg.

Parameters
  • disp_deg (Float[jaxlib._jax.Array, '... 2'])Displacement(s) [dlat, dlon] in degrees. The last axis must have size 2; leading axes are passed through unchanged.

  • lat_deg (Float[jaxlib._jax.Array, ''])Reference latitude in degrees, used for the longitude scaling.

Returns

Same shape as disp_deg, but expressed as [north, east] in metres.

Return type

Float[jaxlib._jax.Array, 2’]