Skip to main content

Geodetic position handling with lazy coordinate conversion between XYZ and LLA

Project description

GeoSol Research Logo

Pos (Position)

Geodetic position handling with lazy coordinate conversion between XYZ (ECEF) and LLA (Lat/Lon/Alt).

Overview

gri-pos provides the Pos class for working with geospatial positions. Initialize with either XYZ or LLA coordinates; the other representation is computed and cached on first access. Pos supports distance calculations, coordinate deltas, translations, and tolerance-based equality.

Vel extends Pos with velocity and Acc extends Vel with acceleration. Both use the same lazy-loaded TriplePoint pattern for frame conversion (ECEF/ENU).

All coordinate types (XYZ, LLA, ENU, NED, AER) are numpy.ndarray subclasses, so they work directly in numpy and scipy operations.

Requires Python 3.12+.

Mathematical Background

Positions use the WGS-84 reference ellipsoid. LLA coordinates are geodetic latitude (degrees), longitude (degrees), and altitude above the ellipsoid (meters). XYZ coordinates are Earth-Centered, Earth-Fixed (ECEF) in meters. Conversion between LLA and XYZ uses iterative methods accurate to sub-millimeter precision.

Equality comparison uses per-coordinate tolerances: LLA defaults to ~1 cm accuracy (1e-7 degrees for lat/lon, 0.01 m for altitude).

Installation

pip install gri-pos

For development:

git clone https://gitlab.com/geosol-foss/python/gri-pos.git
cd gri-pos
uv sync

Quick Start

from gri_pos import Pos

# Create from LLA or XYZ
p1 = Pos.LLA(40.0, -105.0, 1600.0)
p2 = Pos.XYZ(-1270367.0, -4800297.0, 4091069.0)

# Access either representation (lazy-computed)
print(p1.xyz)  # ECEF coordinates (meters)
print(p2.lla)  # Geodetic lat, lon, alt

# Distance calculations
dist = p1.dist_m(p2)                  # 3D Euclidean (meters)
surf = p1.dist_surface_m(p2)          # Vincenty surface distance
fast_surf = p1.dist_surface_simple_m(p2)  # Fast spherical approximation

# Coordinate deltas
enu = p1.delta_enu(p2)   # East, North, Up offset
aer = p1.delta_aer(p2)   # Azimuth, Elevation, Range

# Translation (create new position from offset)
p3 = p1.translate_enu([100, 200, 0])

Pos Class

Creating Positions

from gri_pos import Pos, XYZ, LLA

# Static constructors (preferred)
p = Pos.LLA(40.0, -105.0, 1600.0)
p = Pos.XYZ(-1270367.0, -4800297.0, 4091069.0)

# From existing objects
p = Pos(XYZ(-1270367.0, -4800297.0, 4091069.0))
p = Pos(LLA(40.0, -105.0, 1600.0))
p = Pos(other_pos)  # Copy

Distance Methods

Method Algorithm Accuracy
dist_m(other) 3D Euclidean (XYZ) Exact straight-line
dist_surface_m(other) Vincenty (oblate spheroid) ~0.5 mm
dist_surface_simple_m(other) Spherical approximation Good for <500 km

Delta and Translation

All delta/translate methods accept and return numpy-compatible types:

enu = p1.delta_enu(p2)    # Returns ENU (east, north, up)
ned = p1.delta_ned(p2)    # Returns NED (north, east, down)
aer = p1.delta_aer(p2)    # Returns AER (azimuth_deg, elevation_deg, range_m)
xyz = p1.delta_xyz(p2)    # Returns XYZ delta

p3 = p1.translate_enu(enu)
p3 = p1.translate_ned(ned)
p3 = p1.translate_aer(aer)

Coordinate Types

All types are numpy.ndarray subclasses with named attributes:

Type Attributes Units
XYZ x, y, z meters (ECEF)
LLA lat_deg, lon_deg, alt_m degrees, degrees, meters
ENU east, north, up meters
NED north, east, down meters
AER azim_deg, elev_deg, range_m degrees, degrees, meters

Dependencies

  • gri-utils: Coordinate conversion and distance functions
  • numpy: Array operations

Other Projects

Current list of other GRI FOSS Projects we are building and maintaining.

License

MIT License. See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gri_pos-0.2.3.tar.gz (58.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gri_pos-0.2.3-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

Details for the file gri_pos-0.2.3.tar.gz.

File metadata

  • Download URL: gri_pos-0.2.3.tar.gz
  • Upload date:
  • Size: 58.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gri_pos-0.2.3.tar.gz
Algorithm Hash digest
SHA256 42c1c05b1ee09e62d2b285478b61a9827ae5e604190bc855c9b564f5fe68b7df
MD5 ff44e4dc1244932b49d5dc428501899a
BLAKE2b-256 df236ae37a83aa1b3aaf80ebc1f505d001821982a4588fabbcf08e6b35ff26b0

See more details on using hashes here.

File details

Details for the file gri_pos-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: gri_pos-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for gri_pos-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0eacd92821b49ec7d6737e68f301aaa3c2403393ff2dcc83215e7cfc4d84cc88
MD5 6a7334a9fc6e12a8c0b17833585dab34
BLAKE2b-256 9ea1fba9d59f97fc33da2803a69504e477b9aea429ee2bd77897045411d7b3a9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page