A Python package for working with GPS coordinates
Project description
GPS Toolkit for Python
A powerful, comprehensive Python library for working with GPS coordinates, with support for multiple coordinate systems, distance calculations, and coordinate transformations.
Features
-
Multiple Coordinate Systems
- Decimal degrees (latitude/longitude)
- Universal Transverse Mercator (UTM)
- Military Grid Reference System (MGRS)
-
Distance Calculations
- Haversine formula (great-circle distance)
- Vincenty's formula (ellipsoidal distance)
- Path distances for multiple points
-
Coordinate Conversions
- Convert between lat/lon, UTM, and MGRS
- Parse coordinates from various string formats
- Unified conversion interface
-
Advanced Utilities
- Calculate bearings between points
- Find destination points from a starting position
- Calculate centroids and bounding boxes
- Create coordinate collections with custom properties
Installation
Basic Installation
pip install gps-toolkit-py
With Optional Features
# For visualization capabilities (matplotlib, folium)
pip install gps-toolkit-py[viz]
# For GIS integrations (shapely, geopandas)
pip install gps-toolkit-py[gis]
# For development (testing, linting, etc.)
pip install gps-toolkit-py[dev]
Quick Start
Basic Coordinate Usage
from gps_toolkit_py import Coordinate
# Create a coordinate
nyc = Coordinate(40.7128, -74.0060, name="New York")
sf = Coordinate(37.7749, -122.4194, name="San Francisco")
# Access properties
print(f"NYC is at {nyc.latitude}°N, {abs(nyc.longitude)}°W")
# Output: NYC is at 40.7128°N, 74.006°W
# String representation
print(nyc)
# Output: New York: 40.7128°N, 74.0060°W
Distance Calculations
from gps_toolkit_py import Coordinate
from gps_toolkit_py.distance import haversine_distance, vincenty_distance
# Create coordinates
nyc = Coordinate(40.7128, -74.0060, name="New York")
la = Coordinate(34.0522, -118.2437, name="Los Angeles")
# Calculate distances
haversine_dist = haversine_distance(nyc, la)
vincenty_dist = vincenty_distance(nyc, la)
print(f"Haversine distance: {haversine_dist/1000:.2f} km")
print(f"Vincenty distance: {vincenty_dist/1000:.2f} km")
Coordinate Conversions
from gps_toolkit_py import Coordinate
from gps_toolkit_py.converters import latlon_to_utm, utm_to_latlon, latlon_to_mgrs
# Convert to UTM
lat, lon = 40.7128, -74.0060 # NYC
zone_number, zone_letter, easting, northing = latlon_to_utm(lat, lon)
print(f"UTM: {zone_number}{zone_letter} {easting:.1f}E {northing:.1f}N")
# Convert back to lat/lon
lat2, lon2 = utm_to_latlon(zone_number, zone_letter, easting, northing)
print(f"Back to lat/lon: {lat2:.4f}, {lon2:.4f}")
# Convert to MGRS
mgrs = latlon_to_mgrs(lat, lon)
print(f"MGRS: {mgrs}")
Working with Coordinate Collections
from gps_toolkit_py import Coordinate, CoordinateList
from gps_toolkit_py.calculations import calculate_path_distance, calculate_centroid
# Create a path of coordinates
path = CoordinateList([
Coordinate(40.7128, -74.0060, name="New York"),
Coordinate(39.9526, -75.1652, name="Philadelphia"),
Coordinate(38.9072, -77.0369, name="Washington DC")
])
# Calculate the total path distance
total_distance = calculate_path_distance(path.coordinates)
print(f"Total path distance: {total_distance/1000:.2f} km")
# Find the centroid of the coordinates
centroid = calculate_centroid(path.coordinates)
print(f"Centroid: {centroid}")
API Reference
Core Classes
Coordinate- Basic latitude/longitude coordinate representationUTMCoordinate- UTM coordinate representationMGRSCoordinate- MGRS coordinate representationCoordinateList- Collection of coordinates
Distance Calculation Functions
haversine_distance- Great-circle distancevincenty_distance- Ellipsoidal distancebearing- Calculate bearing between two pointsdestination_point- Find destination from start pointpath_distance- Total distance along a pathmidpoint- Find midpoint between two coordinates
Conversion Functions
latlon_to_utm,utm_to_latlon- UTM conversionsdecimal_to_dms,dms_to_decimal- DMS format conversionslatlon_to_mgrs,mgrs_to_latlon- MGRS conversionsconvert_to_latlon- Unified conversion interface
Calculation Functions
calculate_distance- High-level distance calculatorcalculate_destination- Calculate destination coordinatecalculate_path_distance- Distance along multiple pointscalculate_centroid- Find centroid of multiple coordinatescalculate_bbox- Calculate a bounding box
Requirements
- Python 3.7+
- numpy
- scipy
- pyproj
Contributing
Contributions are welcome! Whether it's bug reports, feature requests, or pull requests, all contributions help improve the library.
- Fork the repository
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add some amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
Before submitting:
- Make sure your code follows the project's style
- Add or update tests as necessary
- Update documentation to reflect your changes
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Thanks to all contributors who have helped improve GPS Toolkit
- Inspired by various GPS and geospatial libraries
Made with ❤️ by the GPS Toolkit Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 gps_toolkit_py-0.1.18.tar.gz.
File metadata
- Download URL: gps_toolkit_py-0.1.18.tar.gz
- Upload date:
- Size: 24.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f8a38afd77dc8b16921edb21679f872403b273aa03f40ec238b3db8406d6e6f
|
|
| MD5 |
68a9b85d60b289c837c04bf1a9750351
|
|
| BLAKE2b-256 |
e0ccd5be6148c79abf041e9481196ded31f13471aaf898dbba0b5ee5e8c527d9
|
File details
Details for the file gps_toolkit_py-0.1.18-py3-none-any.whl.
File metadata
- Download URL: gps_toolkit_py-0.1.18-py3-none-any.whl
- Upload date:
- Size: 26.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1d6d5d4dec01e355ec19f5addbe4ffc0f4d8dc5caaf92547d909b64fdeb5e445
|
|
| MD5 |
8757462a48cd9d7bc1131b574512e102
|
|
| BLAKE2b-256 |
93383f078ed5a51f92c2a8c7eef4b1af2b60c29458758374fc468251cf8643e7
|