How to track the International Space Station's 🛰️current location in real-time using Pandas and Plotly!

·

1 min read

How to track the International Space Station's 🛰️current location in real-time using Pandas and Plotly!

Embarking on a data-driven journey doesn't always mean crunching numbers or plumbing pipelines. No flashy visuals or complex coding—just a straightforward dive into the intersection of Pandas and APIs.

The Setup

We'll leverage the Open Notify API to fetch the ISS's current position. Pandas, a versatile data manipulation library, will help us structure the API response into a readable dataset.

# Pandas & ISS Tracking API
import pandas as pd

# Open Notify API for ISS current location
url = "http://api.open-notify.org/iss-now.json"
df = pd.read_json(url)

# Extracting latitude and longitude
df['latitude'] = df.loc['latitude', 'iss_position']
df['longitude'] = df.loc['longitude', 'iss_position']
df.reset_index(inplace=True)
df = df.drop(['index', 'message'], axis=1)

Plotting the Journey

Plotly Express, a straightforward visualization library, transforms our Pandas DataFrame into a basic an interactive geographical plot.

# Plotting with Plotly Express
import plotly.express as px

fig = px.scatter_geo(df, lat='latitude', lon='longitude')
fig.update_layout(
    title='ISS Current Position 🌐',
    geo=dict(
        showland=True,
        showcountries=True,
        landcolor="rgb(217, 217, 217)",
        countrycolor="rgb(255, 255, 255)"
    )
)
fig.show()

This visualization showcases the ISS's trajectory against the Earth's backdrop.

🚀Feel free to customize or let me know if there's anything specific you'd like to include!

Cheers🛰️