Skip to main content

Fast GPS to local Cartesian coordinate conversion using GeographicLib

Project description

LocalCartesian

Fast GPS to local Cartesian coordinate conversion using GeographicLib.

Description

This package provides efficient conversion between GPS coordinates (latitude, longitude) and local Cartesian coordinates (x, y). It uses the GeographicLib C++ library through Python bindings created with pybind11.

The package exists because GeographicLib's Python bindings don't include the equivalent of the C++ LocalCartesian class, which is essential for many geospatial applications.

Installation

Install from PyPI using uv:

uv add localcartesian

or via pip globally, or inside any Python environment like virtualenv or conda:

pip install localcartesian

Usage

from localcartesian import gps2xy, xy2gps

# Define some GPS coordinates (lat, lon pairs)
gps_coords = [
    [40.7128, -74.0060],  # New York City
    [40.7589, -73.9851],  # Times Square
    [40.6892, -74.0445],  # Statue of Liberty
]

# Define origin point (lat, lon, altitude)
origin = [40.7128, -74.0060, 0.0]  # NYC as origin

# Convert GPS to local Cartesian coordinates
local_coords = gps2xy(gps_coords, origin)
print("Local coordinates:", local_coords)

# Convert back to GPS coordinates
gps_back = xy2gps(local_coords, origin)
print("GPS coordinates:", gps_back)

API Reference

gps2xy(latlon, origin_latlonalt)

Convert GPS coordinates to local Cartesian coordinates.

Parameters:

  • latlon: List of [latitude, longitude] pairs
  • origin_latlonalt: Origin point as [latitude, longitude, altitude]

Returns:

  • List of [x, y] coordinate pairs in meters

xy2gps(xy, origin_latlonalt)

Convert local Cartesian coordinates to GPS coordinates.

Parameters:

  • xy: List of [x, y] coordinate pairs in meters
  • origin_latlonalt: Origin point as [latitude, longitude, altitude]

Returns:

  • List of [latitude, longitude] pairs

Development

Building from Source Locally

Clone the repository and navigate to the project directory:

git clone https://github.com/PastorD/localcartesian.git
cd localcartesian
uv sync --dev

It will fetch the GeographicLib binaries, build the C++ extension, and install the package in editable mode. You can now import and use localcartesian in your Python environment. See examples/basic_usage.py for example usage.

Generate multiple wheels locally

For Linux

uvx cibuildwheel --platform linux \
    --only "cp39-manylinux_x86_64 cp310-manylinux_x86_64 \
            cp311-manylinux_x86_64 cp312-manylinux_x86_64 cp313-manylinux_x86_64"

For MacOS

uvx cibuildwheel --platform macos \
  --only "cp39-macosx_x86_64 cp310-macosx_x86_64 cp311-macosx_x86_64 cp312-macosx_x86_64 \
          cp39-macosx_arm64  cp310-macosx_arm64  cp311-macosx_arm64  cp312-macosx_arm64"

Running Tests

uv sync --extra test
uv run pytest

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

localcartesian-0.1.3.tar.gz (44.0 kB view details)

Uploaded Source

Built Distributions

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

localcartesian-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

localcartesian-0.1.3-cp312-cp312-macosx_11_0_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ x86-64

localcartesian-0.1.3-cp312-cp312-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

localcartesian-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

localcartesian-0.1.3-cp311-cp311-macosx_11_0_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

localcartesian-0.1.3-cp311-cp311-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

localcartesian-0.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

localcartesian-0.1.3-cp310-cp310-macosx_11_0_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

localcartesian-0.1.3-cp310-cp310-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

localcartesian-0.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

localcartesian-0.1.3-cp39-cp39-macosx_11_0_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

localcartesian-0.1.3-cp39-cp39-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file localcartesian-0.1.3.tar.gz.

File metadata

  • Download URL: localcartesian-0.1.3.tar.gz
  • Upload date:
  • Size: 44.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for localcartesian-0.1.3.tar.gz
Algorithm Hash digest
SHA256 2c240374d45e5e599bfb2057e3029c3dc69b467108b3fd457d04911c5bb67fb1
MD5 62e5a03209f196d057bf4475bd694314
BLAKE2b-256 e7437bded8c53753cd2da0d91eee07b043713a23030953595bf84a1d2d0bde84

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3.tar.gz:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c9a0e2bb9de55d0abff18dec8b0c6769af2d9c09a9f70f5bd582b9bbda7962a9
MD5 8ed707ad6867511331714511b3c7fb84
BLAKE2b-256 892a9d510c8c04894dd315841ac2e34b215e17b6aed468195f060f2443296ee3

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp312-cp312-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp312-cp312-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 071977831824c33b0c11c66ca3f8de929b2db59b3cb2aac90519064b73de766f
MD5 f93469d0cfc327076cee637cad478ad7
BLAKE2b-256 c60a0e4a1e93294178095283945e4c86fd3b4fd1c72b79088e23f61957cac2a2

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp312-cp312-macosx_11_0_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa4dd6873d2a94b7e2276bdb21618c3a9e53d7eb516db771ab9ce63daf9c2033
MD5 20e29dd221ef3d0a2e0bc937a5fc8016
BLAKE2b-256 2e9ec05ff2c8c406d577d7f78292aa4ef590d7a836d07cb31ba74602d4799174

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 25c01c798fb3fbbbed47e1c2d38b712c65c964ab587b9244162ff81218569d6f
MD5 4aeba51e712919d80769ec6b99a76a6d
BLAKE2b-256 6e787dafc71da7e3a6f01d4c23007135e241a79a1e6754fa619c2c98fc3a1913

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 8b41c76c57baba470243a40173bbb4583fee4420b4103b5a3cd34333704e48fe
MD5 02f36a8ddcc3ec7eda20caea4c6b852f
BLAKE2b-256 4ca9c97edbd2bf986b2beb554b1f245fbd984552cd9c9a4bbff52efa322171f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp311-cp311-macosx_11_0_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 baed46e4ffd68c8f817f1110c22f8c5280657c9a9230c9a92ab141b3c7b94bea
MD5 771a91b9cdf25511999ea8fb51fbe809
BLAKE2b-256 11cb0222a4b57873c21b178c42e865998f2342f2c1a22a67f21c77201e9afdfe

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b26fa9216ac582a3b8475c4fab8983f25e202ee52bfc4a3c1da2cd658d4951a4
MD5 f933f7d039925f903f66ba01d59933ad
BLAKE2b-256 272aa1787891789337d4edb085c69f4302e90f048448483280003912c4cac283

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 322d4d0588adcb31efd6b83447040e0f1c0f68e91af90ed789180e70d2e6c0b4
MD5 a66b18dee484f01884d68ea63aba130d
BLAKE2b-256 4b7c08f5a1149379224cbc0a7bfdefed7223f1ae00056815122b9ff82e5cc438

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp310-cp310-macosx_11_0_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3b9fd63268025ceece3138eef361b21cf12e49a0706ff5dec300cb5b45d2b535
MD5 e80b507be50a7afd6d6fd5ce11e4228e
BLAKE2b-256 68c026a9544b2db18646dfb522c8e4bad1982e3a7861fa0f464dbac8fb8b476b

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 db78750e5b27f4f6de190a5eab119394a72a7a6344cf7870fdb63c8c482707a7
MD5 354cdc24bb429390af523f9e800c4f1b
BLAKE2b-256 1a1e36bf3deaa71dcce85c720f62dd41d3267274a53c3d532073765b25c4eef6

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 f9c6c248f9877986437ccb70fce109aaf8047ce379c5e0a91e126d5e2b07e9fd
MD5 0c0cd5282262c8b3c669a5deabe1b9a8
BLAKE2b-256 e7faf838ad220fb9f31f8cf0263d2779c6ff8800c5047509c589881e4c6be1c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp39-cp39-macosx_11_0_x86_64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file localcartesian-0.1.3-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for localcartesian-0.1.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11185da2bb33f6c9a1aeb6d778e9b9e429d55612a90c67184bcf942e8267b789
MD5 60a160c65c388c1a0c2c983ef8a6eaf4
BLAKE2b-256 6a8a070a10b65749c20d89ebb53ffdf17a80d63144d320e106536d0f9d88ab2f

See more details on using hashes here.

Provenance

The following attestation bundles were made for localcartesian-0.1.3-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on PastorD/localcartesian

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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