Find the International Space Station!

This short python project aims to plot the position of the International Space Station (ISS) on a visual map!

Did you know that the ISS moves at close to 28,000 kilometres per hour!? This means that its location rapidly changes as time progresses, so this project will plot its whereabouts at any specific time.

space fire galaxy universe

What is an API?

  • API = Application Programming Interface
  • APIs are how computers share information over the internet. We will use an API to find out the coordinates of the ISS, and translate them into a location on a map.
  • We will use the “OpenNotify” API to find the exact location of the ISS, with its latitude and longitude! It also provides a timestamp (in seconds)
  • Call OpenNotify API –> it will receive the location information –> translate this info into a visual experience on a map

Click here to view the coordinates of the ISS using the OpenNotify API. For example:

{"timestamp": 1648763927, "message": "success", "iss_position": {"longitude": "66.9912", "latitude": "-42.5534"}}

Walkthrough of the code

Import the packages we need which are “pandas” and “plotly”. Pandas are a common package used for data science analysis, and plotly will be used to visually plot the ISS on a map.

import pandas as pd
import plotly.express as px

Create variables to store the “url” of the location values from the OpenNotify API, AND to store the dataframe variable.

url = 'http://api.open-notify.org/iss-now.json'
df = pd.read_json(url)

Create new columns called latitude and longitude and output the coordinates as fetched live from the API.

df['latitude'] = df.loc['latitude', 'iss_position']
df['longitude'] = df.loc['longitude', 'iss_position']
df.reset_index(inplace=True)

Remove two unnecessary columns in the table:

df = df.drop(['index', 'message'], axis=1)

This is the final table:

Use “plotly” to plot the location of the ISS on a world map!

figure = px.scatter_geo(df, lat='latitude', lon='longitude')
figure.show()

And, voila! We have successfully completed our “Find the ISS” program. Here is the output (as of 31/03/2022 at 23:09) – I know… I work late 🙂

In the space of 5 minutes (at 23:14), the ISS has already moved a huge distance!

12 hours later (11:14 in the morning), the ISS had travelled all the way to:

Code:

How did you find this article?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

1 thought on “Find the International Space Station!”

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses User Verification plugin to reduce spam. See how your comment data is processed.
error: Sorry, content is protected! For special access, please email contact@bytesofintelligence.co.uk. Thank you.