Spherical geometry functions¶
Quality control suite spherical geometry module.
The spherical geometry module is a simple collection of calculations on a sphere Sourced from https://edwilliams.org/avform147.htm formerly williams.best.vwh.net/avform.htm
- marine_qc.spherical_geometry.angular_distance(lat1, lon1, lat2, lon2)[source]
Calculate the great-circle angular distance between two points on a sphere.
Input latitudes and longitudes should be in degrees. Output distance is returned in radians.
- Parameters:
lat1 (
SequenceNumberType) – Latitude of the first point in degrees.lon1 (
SequenceNumberType) – Longitude of the first point in degrees.lat2 (
SequenceNumberType) – Latitude of the second point in degrees.lon2 (
SequenceNumberType) – Longitude of the second point in degrees.
- Return type:
- Returns:
np.ndarray– Angular great-circle distance between the two points in radians. NaN is returned for any invalid input values.- Raises:
TypeError – If inspect_arrays does not return np.ndarrays.
- marine_qc.spherical_geometry.course_between_points(lat1, lon1, lat2, lon2)[source]
Given two points find the initial true course at point1 inputs are in degrees and output is in degrees.
- Parameters:
lat1 (
SequenceNumberType) – Latitude of the first point in degrees.lon1 (
SequenceNumberType) – Longitude of the first point in degrees.lat2 (
SequenceNumberType) – Latitude of the second point in degrees.lon2 (
SequenceNumberType) – Longitude of the second point in degrees.
- Return type:
- Returns:
SequenceFloatType– Initial true course in degrees at point one along the great circle between point one and point two.- Raises:
TypeError – If inspect_arrays does not return np.ndarrays.
- marine_qc.spherical_geometry.intermediate_point(lat1, lon1, lat2, lon2, f)[source]
Compute the intermediate point along the great-circle path between two points.
Given two lat,lon points find the latitude and longitude that are a fraction f of the great circle distance between them https://edwilliams.org/avform147.htm formerly williams.best.vwh.net/avform.htm#Intermediate
- Parameters:
lat1 (
SequenceNumberType) – Latitude of the first point in degrees.lon1 (
SequenceNumberType) – Longitude of the first point in degrees.lat2 (
SequenceNumberType) – Latitude of the second point in degrees.lon2 (
SequenceNumberType) – Longitude of the second point in degrees.f (
float) – Fraction of distance between the two points.
- Return type:
- Returns:
tupleof(np.ndarray,np.ndarray)– A tuple containing: - Latitude(s) of the intermediate point(s) in degrees. - Longitude(s) of the intermediate point(s) in degrees. The outputs have the same shape as the broadcasted inputs.- Raises:
TypeError – If inspect_arrays does not return np.ndarrays.
- marine_qc.spherical_geometry.lat_lon_from_course_and_distance(lat1, lon1, tc, d)[source]
Calculate latitude and longitude given a starting point, true course and distance.
Uses spherical trigonometry formulas from https://edwilliams.org/avform147.htm to compute the endpoint given a starting latitude and longitude, a true coure (bearing), and a distance traveled along a great-circle path.
- Parameters:
lat1 (
SequenceNumberType) – Latitude of the first point in degrees.lon1 (
SequenceNumberType) – Longitude of the first point in degrees.tc (
float) – True course measured clockwise from north in degrees.d (
float) – Distance travelled in kilometres.
- Return type:
- Returns:
tupleof(SequenceFloatType,SequenceFloatType)– A tuple containing: - Latitude(s) of the intermediate point(s) in degrees. - Longitude(s) of the intermediate point(s) in degrees. The outputs have the same shape as the broadcasted inputs.- Raises:
TypeError – If inspect_arrays does not return np.ndarrays.
- marine_qc.spherical_geometry.sphere_distance(lat1, lon1, lat2, lon2)[source]
Calculate the great circle angular distance between two points on a sphere.
Input latitudes and longitudes should be in degrees. Output distance is returned in radians.
The great circle distance is the shortest distance between any two points on the Earths surface. The calculation is done by first calculating the angular distance between the points and then multiplying that by the radius of the Earth. The angular distance calculation is handled by another function.
- Parameters:
lat1 (
SequenceNumberType) – Latitude of the first point in degrees.lon1 (
SequenceNumberType) – Longitude of the first point in degrees.lat2 (
SequenceNumberType) – Latitude of the second point in degrees.lon2 (
SequenceNumberType) – Longitude of the second point in degrees.
- Return type:
- Returns:
np.ndarray– Angular great-circle distance between the two points in kilometres.- Raises:
TypeError – If inspect_arrays does not return np.ndarrays.