GeoCoords¶
Represents a validated WGS-84 geographic coordinate pair.
Constructor¶
| Parameter | Valid range | Description |
|---|---|---|
lat |
[-90, 90] |
Latitude in decimal degrees |
lon |
[-180, 180] |
Longitude in decimal degrees |
Values are coerced to float automatically. Invalid types raise TypeError; out-of-range values raise ValueError.
Attributes¶
| Attribute | Type | Description |
|---|---|---|
lat |
float |
Latitude |
lon |
float |
Longitude |
Alternative constructors¶
from_tuple¶
from_dict¶
from_utm¶
This method converts projected coordinates to latitude and longitude using pyproj.
Serialisation¶
to_tuple¶
to_dict¶
to_utm¶
target_crs may be any CRS string accepted by pyproj.
to_shapely_point¶
Geodesic calculations¶
distance_to¶
Great-circle distance in km using the Haversine formula.
brasilia = GeoCoords(lat=-15.7801, lon=-47.9292)
manaus = GeoCoords(lat=-3.1190, lon=-60.0217)
print(brasilia.distance_to(manaus)) # ~2689.6 km
bearing_to¶
Initial bearing in degrees (0–360°), measured clockwise from true north.
Notes¶
- Coordinates are always stored internally as decimal degrees in WGS-84.
to_shapely_point()returns aPoint(lon, lat), which matches GIS axis order.- CRS transformers are cached internally to reduce repeated conversion overhead.