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
System Dependencies
Before installing, you need to have GeographicLib installed on your system:
Ubuntu/Debian:
sudo apt-get install libgeographic-dev
macOS (with Homebrew):
brew install geographiclib
Python Package
Install from PyPI:
pip install localcartesian
Or install from source:
git clone <repository-url>
cd localcartesian
pip install .
Usage
import numpy as np
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] pairsorigin_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 metersorigin_latlonalt: Origin point as [latitude, longitude, altitude]
Returns:
- List of [latitude, longitude] pairs
Development
Building from Source
Requirements:
- C++11 compatible compiler
- GeographicLib development headers
- pybind11
- Python development headers
# Install build dependencies
pip install pybind11 setuptools wheel
# Build and install
pip install .
# For development installation
pip install -e .
Running Tests
pip install pytest
pytest tests/
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 Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file localcartesian-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: localcartesian-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66d0103ac3d49967f326e3ba3f87930cb7e2c4691dbf36d1ee2602ac27cad38c
|
|
| MD5 |
108edd239583d9be3f0e27a3bc5c69a7
|
|
| BLAKE2b-256 |
e4b1c213aa4e7ee099fdecc86124b986f07f25b8e9bf6edcebd3d3e952330405
|
File details
Details for the file localcartesian-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: localcartesian-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
823aa99804a32b6156801777aeefa60a8c56b509c4f9450d8843d1c6c12db5ea
|
|
| MD5 |
6ea2930576f2b63753456022448416d0
|
|
| BLAKE2b-256 |
0df415baee916f78bb3227072d38ca940ff057edf20a4623d4db4c0077a05257
|
File details
Details for the file localcartesian-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: localcartesian-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.8 MB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
22b6f490a3e7f947ec41cfb7f5ae12043e84120f5b46fce24e051296d2f9d135
|
|
| MD5 |
1b6a071eb63f023e6841b8f2424be9c0
|
|
| BLAKE2b-256 |
b2054bcaabb33a2b19e80aa66eb3b2bd4c44ecbbeaf8256ef46f40acb99bedbd
|
File details
Details for the file localcartesian-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: localcartesian-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e681b5d9bfa4381306664bdd27a7b2cd7cb9371877900e5d43e08193cd0423e
|
|
| MD5 |
1637831260eddfe7f16d65e31754321a
|
|
| BLAKE2b-256 |
aa10d2fd6e509857dfe67bccff60ed5d188f1d285e00da37b5f4df385cc96e3c
|
File details
Details for the file localcartesian-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: localcartesian-0.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2474b7fc3778b644257272c0b9a6ae2254e49a280e49098d50a18889a26c83f
|
|
| MD5 |
b128ea3cf1c211dfd1fecfbd34982c56
|
|
| BLAKE2b-256 |
0a51445e5cb5b0e4afcd55c3e51a94f39aa244a688f2db488a1a612214dc5483
|