navtools#
Simple conversion functions from lat/lon to string
Example usage#
# import this module
from themachinethatgoesping.navigation import navtools as nt
print("[degrees] 123.45678° ->",nt.latitude_to_string(123.45678,"degrees",2))
print("[minutes] 123.45678° ->",nt.latitude_to_string(123.45678,"minutes",2))
print("[seconds] 123.45678° ->",nt.latitude_to_string(123.45678,"seconds",2))
print()
print("[degrees] -123.45678° ->",nt.latitude_to_string(-123.45678,"degrees",2))
print("[minutes] -123.45678° ->",nt.latitude_to_string(-123.45678,"minutes",2))
print("[seconds] -123.45678° ->",nt.latitude_to_string(-123.45678,"seconds",2))
print()
print("[degrees] -123.45678° ->",nt.longitude_to_string( 123.45678,"degrees",2))
print("[minutes] -123.45678° ->",nt.longitude_to_string( 123.45678,"minutes",2))
print("[seconds] -123.45678° ->",nt.longitude_to_string(-123.45678,"seconds",3))
# [degrees] 123.45678° -> 123.46°N
# [minutes] 123.45678° -> 123°27.41'N
# [seconds] 123.45678° -> 123°27'24.41"N
# [degrees] -123.45678° -> 123.46°E
# [minutes] -123.45678° -> 123°27.41'S
# [seconds] -123.45678° -> 123°27'24.41"S
# [degrees] 123.45678° -> 123.46°E
# [minutes] 123.45678° -> 123°27.41'E
# [seconds] -123.45678° -> 123°27'24.408"W
Module API#
Convenient functions for converting latlon and utm strings.
- compute_latlon_distance_m(*args, **kwargs)#
Overloaded function.
compute_latlon_distance_m(lat1: float, lon1: float, lat2: float, lon2: float) -> float
Compute the distance in meters between two latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_float
: Floating-point type for latitude and longitude values.
- Parameter
lat1
: Latitude of the first coordinate.
- Parameter
lon1
: Longitude of the first coordinate.
- Parameter
lat2
: Latitude of the second coordinate.
- Parameter
lon2
: Longitude of the second coordinate.
- Returns:
Distance between the two coordinates in meters.
compute_latlon_distance_m(lat1: float, lon1: float, lat2: float, lon2: float) -> float
Compute the distance in meters between two latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_float
: Floating-point type for latitude and longitude values.
- Parameter
lat1
: Latitude of the first coordinate.
- Parameter
lon1
: Longitude of the first coordinate.
- Parameter
lat2
: Latitude of the second coordinate.
- Parameter
lon2
: Longitude of the second coordinate.
- Returns:
Distance between the two coordinates in meters.
compute_latlon_distance_m(geolocation_latlon_1: themachinethatgoesping.navigation.datastructures.GeolocationLatLon, geolocation_latlon_2: themachinethatgoesping.navigation.datastructures.GeolocationLatLon) -> float
Compute the distance in meters between two latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_float
: Floating-point type for latitude and longitude values.
- Parameter
lat1
: Latitude of the first coordinate.
- Parameter
lon1
: Longitude of the first coordinate.
- Parameter
lat2
: Latitude of the second coordinate.
- Parameter
lon2
: Longitude of the second coordinate.
- Returns:
Distance between the two coordinates in meters.
compute_latlon_distance_m(geolocation_latlon_1: themachinethatgoesping.navigation.datastructures.SensordataLatLon, geolocation_latlon_2: themachinethatgoesping.navigation.datastructures.SensordataLatLon) -> float
Compute the distance in meters between two latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_float
: Floating-point type for latitude and longitude values.
- Parameter
lat1
: Latitude of the first coordinate.
- Parameter
lon1
: Longitude of the first coordinate.
- Parameter
lat2
: Latitude of the second coordinate.
- Parameter
lon2
: Longitude of the second coordinate.
- Returns:
Distance between the two coordinates in meters.
compute_latlon_distance_m(geolocation_latlon_1: Tuple[float, float], geolocation_latlon_2: Tuple[float, float]) -> float
Compute the distance in meters between two latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_float
: Floating-point type for latitude and longitude values.
- Parameter
lat1
: Latitude of the first coordinate.
- Parameter
lon1
: Longitude of the first coordinate.
- Parameter
lat2
: Latitude of the second coordinate.
- Parameter
lon2
: Longitude of the second coordinate.
- Returns:
Distance between the two coordinates in meters.
compute_latlon_distance_m(geolocation_latlon_1: Tuple[float, float], geolocation_latlon_2: Tuple[float, float]) -> float
Compute the distance in meters between two latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_float
: Floating-point type for latitude and longitude values.
- Parameter
lat1
: Latitude of the first coordinate.
- Parameter
lon1
: Longitude of the first coordinate.
- Parameter
lat2
: Latitude of the second coordinate.
- Parameter
lon2
: Longitude of the second coordinate.
- Returns:
Distance between the two coordinates in meters.
- compute_latlon_distances_m(*args, **kwargs)#
Overloaded function.
compute_latlon_distances_m(latitudes: numpy.ndarray[numpy.float32], longitudes: numpy.ndarray[numpy.float32]) -> numpy.ndarray[numpy.float64]
Compute the distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of distances between consecutive coordinates in meters.
compute_latlon_distances_m(latitudes: numpy.ndarray[numpy.float64], longitudes: numpy.ndarray[numpy.float64]) -> numpy.ndarray[numpy.float64]
Compute the distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of distances between consecutive coordinates in meters.
compute_latlon_distances_m(geolocations_latlon: List[themachinethatgoesping.navigation.datastructures.GeolocationLatLon]) -> numpy.ndarray[numpy.float64]
Compute the distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of distances between consecutive coordinates in meters.
compute_latlon_distances_m(geolocations_latlon: List[themachinethatgoesping.navigation.datastructures.SensordataLatLon]) -> numpy.ndarray[numpy.float64]
Compute the distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of distances between consecutive coordinates in meters.
compute_latlon_distances_m(geolocations_latlon: List[Tuple[float, float]]) -> numpy.ndarray[numpy.float64]
Compute the distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of distances between consecutive coordinates in meters.
compute_latlon_distances_m(geolocations_latlon: List[Tuple[float, float]]) -> numpy.ndarray[numpy.float64]
Compute the distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of distances between consecutive coordinates in meters.
- cumulative_latlon_distances_m(*args, **kwargs)#
Overloaded function.
cumulative_latlon_distances_m(latitudes: numpy.ndarray[numpy.float32], longitudes: numpy.ndarray[numpy.float32]) -> numpy.ndarray[numpy.float64]
Compute the cumulative distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of cumulative distances between consecutive coordinates in meters.
cumulative_latlon_distances_m(latitudes: numpy.ndarray[numpy.float64], longitudes: numpy.ndarray[numpy.float64]) -> numpy.ndarray[numpy.float64]
Compute the cumulative distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of cumulative distances between consecutive coordinates in meters.
cumulative_latlon_distances_m(geolocations_latlon: List[themachinethatgoesping.navigation.datastructures.GeolocationLatLon]) -> numpy.ndarray[numpy.float64]
Compute the cumulative distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of cumulative distances between consecutive coordinates in meters.
cumulative_latlon_distances_m(geolocations_latlon: List[themachinethatgoesping.navigation.datastructures.SensordataLatLon]) -> numpy.ndarray[numpy.float64]
Compute the cumulative distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of cumulative distances between consecutive coordinates in meters.
cumulative_latlon_distances_m(geolocations_latlon: List[Tuple[float, float]]) -> numpy.ndarray[numpy.float64]
Compute the cumulative distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of cumulative distances between consecutive coordinates in meters.
cumulative_latlon_distances_m(geolocations_latlon: List[Tuple[float, float]]) -> numpy.ndarray[numpy.float64]
Compute the cumulative distances in meters between consecutive latitude-longitude coordinates using the WGS84 ellipsoid.
- Template parameter
T_return_container
: Type of container to store the distances.
- Template parameter
T_float_container
: Type of container that holds latitude and longitude values as floats.
- Parameter
latitudes
: Vector of latitude values.
- Parameter
longitudes
: Vector of longitude values.
- Returns:
Vector of cumulative distances between consecutive coordinates in meters.
- latitude_to_string(*args, **kwargs)#
Overloaded function.
latitude_to_string(latitude: float, format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> str
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns:
converted latitude string
latitude_to_string(latitude: List[float], format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> List[str]
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns:
converted latitude string
- latlon_to_utm(latitude: List[float], longitude: List[float], setzone: int) → Tuple[List[float], List[float], int, bool]#
- longitude_to_string(*args, **kwargs)#
Overloaded function.
longitude_to_string(longitude: float, format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> str
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns:
converted latitude string
longitude_to_string(longitude: List[float], format: themachinethatgoesping.navigation.navtools.t_latlon_format = <t_latlon_format.minutes: 1>, precision: int = 6) -> List[str]
convert a latitude value to a string
- Parameter
latitude
: value to be converted
- Parameter
precision
: number of digits behind the .
- Parameter
format
: latlon format (degrees°N/S, degrees°minutes’N/S or degrees°minutes’seconds’’N/S)
- Returns:
converted latitude string
- class t_latlon_format#
lat/lon format specifications
Members:
degrees
minutes
seconds
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: themachinethatgoesping.navigation.navtools.t_latlon_format, value: int) -> None
__init__(self: themachinethatgoesping.navigation.navtools.t_latlon_format, str: str) -> None
Construct this enum type from string
- property name#
- str(self: t_latlon_format) → str#
- utm_to_latlon(*args, **kwargs)#
Overloaded function.
utm_to_latlon(northing: List[float], easting: List[float], zone: int, northern_hemisphere: bool) -> Tuple[List[float], List[float]]
utm_to_latlon(northing: List[float], easting: List[float], zone: List[int], northern_hemisphere: List[bool]) -> Tuple[List[float], List[float]]