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
. .init_venv.sh

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.2.tar.gz (55.9 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.2-py3-none-any.whl (23.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gri_pos-0.2.2.tar.gz
  • Upload date:
  • Size: 55.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.2.tar.gz
Algorithm Hash digest
SHA256 8693e39a37b26d825a876da573716a52c2604ed5909beae2b4df492ea6a3d3dd
MD5 997e434f0248f8d96c77ed13ebcbedd2
BLAKE2b-256 879af7c57f0c2b86580b8099c5a8f5c87a42311156c5141aef7d002eb5fd1a5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gri_pos-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 23.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 afe1ea7247802cb4d673c3b65b9abf70425c068912d7d40656c4ecb058faa4c8
MD5 ab178f9e914a7c5271e5aa6881a84878
BLAKE2b-256 e244e5cf5d7ba23865543dcd8cc1cfd95afbbb65fc2c10a75654589204ef1287

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