larzgeo
Geospatial basics in pure Python. Zero dependencies.
The handful of geo operations most apps actually need - distance, bearing, geohashing, bounding boxes, and point-in-polygon - without GDAL, shapely, or any dependency.
from larzgeo import haversine, geohash_encode, point_in_polygon
haversine(51.5074, -0.1278, 48.8566, 2.3522) # London->Paris ~343 km
geohash_encode(57.64911, 10.40744, 11) # 'u4pruydqqvj'
point_in_polygon((2, 2), [(0, 0), (0, 4), (4, 4), (4, 0)]) # True
Why
- Just the essentials, correct. Great-circle (haversine) distance in km/mi/m/
nautical-mi, initial bearing,
destination(project a point),midpoint,bounding_box(to pre-filter a radius query cheaply), geohash encode/decode (tested against the canonicalu4pruydqqvjvector), and ray-casting point-in-polygon that handles concave shapes. - No heavyweight geo stack. GDAL/shapely are powerful and huge; for "how far is X from Y", "is this point in this area", and "give me a geohash", this installs anywhere in seconds.
- Zero dependencies.
Install
pip install larzgeo
Usage
from larzgeo import (haversine, bearing, destination, midpoint,
bounding_box, geohash_encode, geohash_decode, point_in_polygon)
haversine(lat1, lon1, lat2, lon2, unit="km") # or "mi" / "m" / "nmi"
bearing(lat1, lon1, lat2, lon2) # degrees, 0=N 90=E
destination(lat, lon, bearing_deg, distance) # -> (lat, lon)
bounding_box(lat, lon, radius_km) # (min_lat, min_lon, max_lat, max_lon)
geohash_encode(lat, lon, precision=12)
geohash_decode(hash) # -> (lat, lon)
point_in_polygon((x, y), [(x1, y1), ...]) # ray casting
Tests
python -m unittest discover -s tests -v # 17 tests incl. geohash vector + concave polygons
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter.
License
MIT (c) larz-scripter
Metadata
Release files for larzgeo 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| larzgeo-0.1.0.tar.gz | 5.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzgeo-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.4 kB
Release files / larzgeo-0.1.0.tar.gz
| Download URL | larzgeo-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
29ad955a13061497374a3a7bec48326dd1f9558e597d93accd2bcfc314d94f64
|
|
BLAKE2b-256 checksum How to use checksums |
87a6fb38c6913e7193b687ac56620e1f2c39cf5c88eaff74a96448795874e01e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzgeo-0.1.0-py3-none-any.whl
| Download URL | larzgeo-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5430bd183a4f40e32c1530b416260824995d429e65a021ef89087ba6f780eae7
|
|
BLAKE2b-256 checksum How to use checksums |
823eb89a283be21b05b13fcc68cf4a5f2c01d0bdfb308a6ad31390de569c22a7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzgeo 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.