International Space Station Realtime Location

In this article, we’ll talk about some libraries in Python, learn about API and then write a program to fetch data from API to make a fun interactive map plot.
 

Python

 
Python is one of the easiest and most widely-used programming languages across the globe,
  • Taught as a beginning programming language to students
  • Clear syntax facilitates, ease of understanding and code indentation
  • Active communities of libraries and modules developers

Pandas

 
Pandas is a software library that is written for data manipulation and analysis, especially for Python. While Python supports lists and dictionaries for the manipulation of structured data, it is not well-suited for manipulating numerical tables, such as those stored in CSV files or JSON files.
 

Plotly Express

 
Plotly Express is a wrapper for Plotly which enables developers to create, deploy and scale interactive visualizations.
 

Dataframe

 
Dataframe in Pandas are two-dimensional and heterogeneous tabular data that are mutable in size. Ie. Its size can be changed.
 

API

 
Application Programming Interface (API) is basically just an interface through which two systems - software applications or hardware-software intermediary can communicate to each other.
 

Anaconda

 
Anaconda is a distribution for scientific computing which is an easy-to-install free package manager and environment manager and has a collection of over 720 open-source packages offering free community support for R and Python programming languages. It supports Windows, Linux, and Mac OS and also ships with Jupyter Notebook.
 

Jupyter Notebook

 
Jupyter Notebook is an amalgamation of an IDE and also an educational tool for presentation which is used extensively and widely mostly for programming for scientific computing.
 

JSON

 
JSON is the abbreviation of JavaScript Object Notation which is widely used to transfer data between web pages and servers. It is an open standard file format which is readable in the text by humans and acts as a mean to store and transport data.
 

Overview

 
Here, we will  try to make a small interesting fun program for beginner level to understand python, using some of the libraries for Python with an API. We’ll use the API to find the current location of the International Space Station and plot it in Map.
 

ISS

 
International Space Station is a station in Earth’s lower orbit that consists of modular components and is a collaboration between space agencies from different nations. The agencies include NAS, JAXA, ESA, CSA, and Roscosmos. International Space Station moves at around 28,000 km/h and thus the location changes continuously. We’ll try to locate it with this small program.
 
The simple API we’ll use returns the current location of the ISS. It returns the current latitude and longitude of the space station for the valid timestamp and takes no inputs.
 
Firstly, we import the libraries Pandas and Plotly express into our notebook.
  1. import pandas as PD  
  2. import plotly.express as px   
Use the API provided, which is scraped from the information published by NASA, 
 
We set the URL link as a string to variable ‘URL’.
 
url='http://api.open-notify.org/iss-now.json'
 
Using Dataframe
  1. dataframe=pd.read_json(url)  
  2. dataframe  
International Space Station Realtime Location
 
Changing order of Dataframe as per our need,
  1. dataframe['latitude'] =dataframe.loc['latitude','iss_position'] dataframe['longitude'] =dataframe.loc['longitude','iss_position'] dataframe.reset_index(inplace=True)  
  2. dataframe   
International Space Station Realtime Location
 
Deleting the columns, we donot require,
  1. dataframe=dataframe.drop(['index''message'], axis =1)   
What our final dataframe looks like before we plot our map,
 
International Space Station Realtime Location
 
Using Scatter Plot into the Geographical map,
  1. figure =px.scatter_geo(dataframe, lat='latitude', lon='longitude')  
  2. figure.show()  
International Space Station Realtime Location

Conclusion

 
Hence, today we learned about Python and some of its libraries and API and used one in a real-world scenario to see how we can fetch data and use all of these components to make an application that can make an impact in real life. This was an article for beginners wanting to try a hands-on experience with components. The code can be accessed through this Github link.


Similar Articles