While cleaning up old files I rediscovered this little Python script.
It fetches the current location of the International Space Station (ISS) and displays it as a red dot on a world map.
Completely useless in everyday life, but fun to watch every now and then.
I like to use PyCharm and VS Code for this.
What the script does:
The script:
import requests
import plotly.express as px
# Get current ISS position
url = "http://api.open-notify.org/iss-now.json"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
iss_pos = data["iss_position"]
lat = float(iss_pos["latitude"])
lon = float(iss_pos["longitude"])
timestamp = data["timestamp"]
print(f"Aktuelle ISS-Position (Stand {timestamp}):")
print(f" Latitude: {lat:.4f}°")
print(f" Longitude: {lon:.4f}°")
# Create map
fig = px.scatter_geo(
lat=[lat],
lon=[lon],
title="ISS Live Position 🚀",
projection="natural earth",
color_discrete_sequence=["red"],
size_max=20,
opacity=0.9
)
fig.update_geos(
showcountries=True,
countrycolor="Black",
showland=True,
landcolor="lightgray",
showocean=True,
oceancolor="azure"
)
fig.update_layout(
title_font_size=20,
height=600,
margin={"r":0,"t":50,"l":0,"b":0}
)
fig.show()
else:
print("Fehler beim API-Aufruf:", response.status_code)
Beim Aufräumen alter Dateien habe ich dieses kleine Python-Skript wiederentdeckt.
Es holt die aktuelle Position der Internationalen Raumstation (ISS) und zeigt sie als roten Punkt auf einer Weltkarte an.
Im Alltag völlig unnütz, aber ab und zu ganz nett anzuschauen.
Ich nutze dafür am liebsten PyCharm und VS Code.
Was das Skript macht:
Das Skript:
import requests
import plotly.express as px
# Aktuelle ISS-Position holen
url = "http://api.open-notify.org/iss-now.json"
response = requests.get(url)
if response.status_code == 200:
data = response.json()
iss_pos = data["iss_position"]
lat = float(iss_pos["latitude"])
lon = float(iss_pos["longitude"])
timestamp = data["timestamp"]
print(f"Aktuelle ISS-Position (Stand {timestamp}):")
print(f" Latitude: {lat:.4f}°")
print(f" Longitude: {lon:.4f}°")
# Schöne Karte erstellen
fig = px.scatter_geo(
lat=[lat],
lon=[lon],
title="ISS Live Position 🚀",
projection="natural earth",
color_discrete_sequence=["red"],
size_max=20,
opacity=0.9
)
fig.update_geos(
showcountries=True,
countrycolor="Black",
showland=True,
landcolor="lightgray",
showocean=True,
oceancolor="azure"
)
fig.update_layout(
title_font_size=20,
height=600,
margin={"r":0,"t":50,"l":0,"b":0}
)
fig.show()
else:
print("Fehler beim API-Aufruf:", response.status_code)
Ein kleiner, harmloser Spaß mit Python und einer öffentlichen API.
Dieser Code ist mein geistiges Eigentum. Wer mag, darf gerne damit spielen.