nvector.objects.GeoPath¶
-
class
nvector.objects.
GeoPath
(positionA, positionB)[source][source]¶ - Geographical path between two positions in Frame E
Parameters: positionA, positionB: Nvector, GeoPoint or ECEFvector objects
The path is defined by the line between position A and B, decomposed in E.
Examples
Example 5: “Surface distance”
Find the surface distance sAB (i.e. great circle distance) between two positions A and B. The heights of A and B are ignored, i.e. if they don’t have zero height, we seek the distance between the points that are at the surface of the Earth, directly above/below A and B. The Euclidean distance (chord length) dAB should also be found. Use Earth radius 6371e3 m. Compare the results with exact calculations for the WGS-84 ellipsoid.
- Solution for a sphere:
>>> import numpy as np >>> import nvector as nv >>> frame_E = nv.FrameE(a=6371e3, f=0) >>> positionA = frame_E.GeoPoint(latitude=88, longitude=0, degrees=True) >>> positionB = frame_E.GeoPoint(latitude=89, longitude=-170, degrees=True)
>>> s_AB, _azia, _azib = positionA.distance_and_azimuth(positionB) >>> p_AB_E = positionB.to_ecef_vector() - positionA.to_ecef_vector() >>> d_AB = np.linalg.norm(p_AB_E.pvector, axis=0)[0]
>>> msg = 'Ex5: Great circle and Euclidean distance = {}' >>> msg = msg.format('{:5.2f} km, {:5.2f} km') >>> msg.format(s_AB / 1000, d_AB / 1000) 'Ex5: Great circle and Euclidean distance = 332.46 km, 332.42 km'
- Alternative sphere solution:
>>> path = nv.GeoPath(positionA, positionB) >>> s_AB2 = path.track_distance(method='greatcircle').ravel() >>> d_AB2 = path.track_distance(method='euclidean').ravel() >>> msg.format(s_AB2[0] / 1000, d_AB2[0] / 1000) 'Ex5: Great circle and Euclidean distance = 332.46 km, 332.42 km'
- Exact solution for the WGS84 ellipsoid:
>>> wgs84 = nv.FrameE(name='WGS84') >>> point1 = wgs84.GeoPoint(latitude=88, longitude=0, degrees=True) >>> point2 = wgs84.GeoPoint(latitude=89, longitude=-170, degrees=True) >>> s_12, _azi1, _azi2 = point1.distance_and_azimuth(point2)
>>> p_12_E = point2.to_ecef_vector() - point1.to_ecef_vector() >>> d_12 = np.linalg.norm(p_12_E.pvector, axis=0)[0] >>> msg = 'Ellipsoidal and Euclidean distance = {:5.2f} km, {:5.2f} km' >>> msg.format(s_12 / 1000, d_12 / 1000) 'Ellipsoidal and Euclidean distance = 333.95 km, 333.91 km'
- See also
- Example 5 at www.navlab.net
Example 6 “Interpolated position”
Given the position of B at time t0 and t1, n_EB_E(t0) and n_EB_E(t1).
Find an interpolated position at time ti, n_EB_E(ti). All positions are given as n-vectors.
- Solution:
>>> import nvector as nv >>> wgs84 = nv.FrameE(name='WGS84') >>> n_EB_E_t0 = wgs84.GeoPoint(89, 0, degrees=True).to_nvector() >>> n_EB_E_t1 = wgs84.GeoPoint(89, 180, degrees=True).to_nvector() >>> path = nv.GeoPath(n_EB_E_t0, n_EB_E_t1)
>>> t0 = 10. >>> t1 = 20. >>> ti = 16. # time of interpolation >>> ti_n = (ti - t0) / (t1 - t0) # normalized time of interpolation
>>> g_EB_E_ti = path.interpolate(ti_n).to_geo_point()
>>> lat_ti, lon_ti = g_EB_E_ti.latitude_deg, g_EB_E_ti.longitude_deg >>> msg = 'Ex6, Interpolated position: lat, long = {} deg, {} deg' >>> msg.format(lat_ti, lon_ti) 'Ex6, Interpolated position: lat, long = [ 89.7999805] deg, [ 180.] deg'
- See also
- Example 6 at www.navlab.net
Example 9: “Intersection of two paths”
Define a path from two given positions (at the surface of a spherical Earth), as the great circle that goes through the two points.
Path A is given by A1 and A2, while path B is given by B1 and B2.
Find the position C where the two paths intersect.
- Solution:
>>> import nvector as nv >>> pointA1 = nv.GeoPoint(10, 20, degrees=True) >>> pointA2 = nv.GeoPoint(30, 40, degrees=True) >>> pointB1 = nv.GeoPoint(50, 60, degrees=True) >>> pointB2 = nv.GeoPoint(70, 80, degrees=True) >>> pathA = nv.GeoPath(pointA1, pointA2) >>> pathB = nv.GeoPath(pointB1, pointB2)
>>> pointC = pathA.intersection(pathB)
>>> lat, lon = pointC.latitude_deg, pointC.longitude_deg >>> msg = 'Ex9, Intersection: lat, long = {:4.2f}, {:4.2f} deg' >>> msg.format(lat[0], lon[0]) 'Ex9, Intersection: lat, long = 40.32, 55.90 deg'
- See also
- Example 9 at www.navlab.net
Example 10: “Cross track distance”
Path A is given by the two positions A1 and A2 (similar to the previous example).
Find the cross track distance sxt between the path A (i.e. the great circle through A1 and A2) and the position B (i.e. the shortest distance at the surface, between the great circle and B).
Also find the Euclidean distance dxt between B and the plane defined by the great circle. Use Earth radius 6371e3.
- Solution:
>>> import nvector as nv >>> frame = nv.FrameE(a=6371e3, f=0) >>> pointA1 = frame.GeoPoint(0, 0, degrees=True) >>> pointA2 = frame.GeoPoint(10, 0, degrees=True) >>> pointB = frame.GeoPoint(1, 0.1, degrees=True)
>>> pathA = nv.GeoPath(pointA1, pointA2)
>>> s_xt = pathA.cross_track_distance(pointB, method='greatcircle').ravel() >>> d_xt = pathA.cross_track_distance(pointB, method='euclidean').ravel() >>> val_txt = '{:4.2f} km, {:4.2f} km'.format(s_xt[0]/1000, d_xt[0]/1000) >>> 'Ex10: Cross track distance: s_xt, d_xt = {}'.format(val_txt) 'Ex10: Cross track distance: s_xt, d_xt = 11.12 km, 11.12 km'
- See also
- Example 10 at www.navlab.net
Methods
__init__
(positionA, positionB)cross_track_distance
(point[, method, radius])Return cross track distance from the path to a point. interpolate
(ti)Return the interpolated point along the path intersection
(path)Return the intersection between the paths nvectors
()Return positionA and positionB as n-vectors track_distance
([method, radius])Return the distance of the path.