Tools to handle representations of geographic coordinates
Functionality to convert between different representations of geo-coordinates.
In particular, we support conversion of coordinates in the notation used for the World Atlas of Language Structures, e.g. (12d10N, 92d49E), to floating point latitude and longitude values.
- class clldutils.coordinates.Coordinates(lat, lon, format='alnum')[source]
A (lat, lon) pair, that can be represented in various formats.
>>> c = Coordinates('13dN', 0) >>> assert c.latitude >= 13 >>> assert c.latitude <= 13.1 >>> c = Coordinates(0, 0) >>> assert c.lat_to_string() == '0dN' >>> assert c.lon_to_string() == '0dE' >>> c = Coordinates(12.17, 92.83) >>> assert c.lat_to_string() == '12d10N' >>> assert c.lon_to_string() == '92d49E' >>> c = Coordinates(-12.17, -92.83) >>> assert c.lat_to_string() == '12d10S' >>> c.lat_to_string(format=None) '12° 10′ 12″ S' >>> c.lat_to_string(format='ascii') '12°10'12.000000"S' >>> assert c.lon_to_string() == '92d49W' >>> lat, lon = '12d30N', '60d30E' >>> c = Coordinates(lat, lon) >>> assert c.lat_to_string() == lat >>> assert c.lon_to_string() == lon
- clldutils.coordinates.dec2degminsec(dec, no_seconds=False)[source]
convert a floating point number of degrees to a triple (int degrees, int minutes, float seconds)
>>> assert dec2degminsec(30.50) == (30, 30, 0.0)
- Parameters:
no_seconds (
bool
) –- Return type:
typing.Tuple
[float
,float
,float
]