GPS utilities¶
Utility functions with regard to the GPS coordinates
The valid degree is within (-180, 180]
Reference:
GSP to distance¶
-
mtldp.utils.
haversine_distance
(coord1, coord2)¶ Get the distance between two gps coordinates.
-
mtldp.utils.
get_trace_length
(lat_list, lon_list)¶ Get the length of a trajectory data.
- Parameters
lat_list – latitude list
lon_list – longitude list
- Returns
lengths of the trajectory by meters
GPS to heading/angle¶
-
mtldp.utils.
get_directed_segment_heading
(start_coord, end_coord)¶ Calculate the heading of a directed line segment.
Use cosine approximation, if the distance between the two points is too large, then this will not give you the write output
-
mtldp.utils.
get_gps_trace_heading_info
(lat_list, lon_list)¶ Get the heading angle given the lat and lon list.
- Parameters
lat_list –
lon_list –
- Returns
forward_heading, forward_weighted_heading, backward_heading, backward_weighted_heading
-
mtldp.utils.
get_angle_difference
(degree1, degree2)¶ Get the difference between two angle (the output is always less than 180)
-
mtldp.utils.
get_closest_angle
(degree, degree_list)¶ Get the closest angle (return the index) among a set of options.
- Parameters
degree –
degree_list –
- Returns
-
mtldp.utils.
reverse_degree
(degree)¶ Get the reverse degree
- Parameters
degree –
- Returns
GPS shift and segmentation¶
-
mtldp.utils.
segment_gps_trace
(lat_list, lon_list, split_into=10)¶ Split the gps trace evenly.
- Parameters
lat_list –
lon_list –
split_into –
- Returns
-
mtldp.utils.
shift_geometry
(geometry, shift_distance=7, shift_direction='left')¶ Shift the geometry towards a certain direction.