-
Notifications
You must be signed in to change notification settings - Fork 119
Expand file tree
/
Copy pathfrom_norway.py
More file actions
31 lines (22 loc) · 922 Bytes
/
Copy pathfrom_norway.py
File metadata and controls
31 lines (22 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env python3
"""Live decode of the Norwegian Coastal Administration's public AIS feed.
A free, registration-less TCP/IP feed of AIS traffic around Norwegian waters,
released under the Norwegian Licence for Open Government Data (NLOD 1.0):
https://kystverket.no/en/navigation-and-monitoring/ais/access-to-ais-data/
Useful for kicking the tyres without setting up a receiver.
Usage: python from_norway.py
"""
import aiscat
HOST, PORT = "153.44.253.27", 5631
POSITION_TYPES = {1, 2, 3, 18, 19, 27}
def main():
for msg in aiscat.from_tcp(HOST, PORT, country=True):
if msg["type"] in POSITION_TYPES and "lat" in msg:
print(
f"{msg['mmsi']:>10} "
f"{msg.get('country_code', '??'):2} "
f"{msg['lat']:>9.5f}, {msg['lon']:>9.5f} "
f"{msg.get('speed', 0):>5.1f} kn"
)
if __name__ == "__main__":
main()