Created
February 15, 2022 21:27
-
-
Save maxim75/32a61abbd9ea4a857bd18a174411bf63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pynmea2 | |
nmea_data = open("data/gps_data_20220215-070028.nmea", "rb") | |
coordinates_data = [] | |
for message_bytes in nmea_data.readlines(): | |
try: | |
message = message_bytes.decode("utf-8").replace("\n", "").replace("\r", "") | |
parsed_message = pynmea2.parse(message) | |
except: | |
# skip invalid sentences | |
continue | |
cga_data = {} | |
# process only GGA messages | |
if parsed_message.sentence_type == "GGA": | |
for attr in ["timestamp", "latitude", "longitude", "latitude", "horizontal_dil", "num_sats", "gps_qual"]: | |
cga_data[attr] = getattr(parsed_message, attr) | |
coordinates_data.append(cga_data) | |
coordinates_data[0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment