- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How To Track ISS (International Space Station) Using Python?
Exploring the whereabouts of the International Space Station (ISS) and witnessing its real−time movements can be an exhilarating experience. The following article aims to showcase how Python can be utilized to track the ISS, utilizing the ISS API provided by Open Notify and visualizing its location on an interactive world map with the aid of the `folium` library.
Installing the Required Libraries
Before we embark on our ISS tracking journey, it is necessary to install a couple of libraries: `requests`, which facilitates API calls, and `folium`, which empowers the creation of captivating interactive maps.
pip install requests folium
Retrieving ISS Location Data
To retrieve the current location of the ISS, we shall employ the ISS API provided by Open Notify. This API furnishes us with latitude and longitude coordinates representing the ISS's position.
import requests def acquire_iss_location(): response = requests.get("http://api.open-notify.org/iss-now.json") data = response.json() latitude = float(data["iss_position"]["latitude"]) longitude = float(data["iss_position"]["longitude"]) return latitude, longitude iss_latitude, iss_longitude = acquire_iss_location() print(f"ISS's present location: Latitude: {iss_latitude}, Longitude: {iss_longitude}")
Output
ISS's present location: Latitude: 47.3335, Longitude: 49.9148
Within this code snippet, a function named `acquire_iss_location()` is defined. This function sends a GET request to Open Notify's ISS API and subsequently parses the received JSON response, extracting the latitude and longitude coordinates of the ISS. Finally, we print the current location of the ISS.
Visualizing ISS Location on an Interactive Map
To visualize the ISS's location on an interactive map, we will make use of the `folium` library. This library empowers us to create captivating world maps and plot the ISS's current position upon it.
import folium def generate_iss_map(latitude, longitude): iss_map = folium.Map(location=[latitude, longitude], zoom_start=2) folium.Marker([latitude, longitude], tooltip="ISS Location", popup="International Space Station", icon=folium.Icon(color="red", icon="info-sign")).add_to(iss_map) return iss_map iss_map = generate_iss_map(iss_latitude, iss_longitude) iss_map.save("iss_location.html")
Inside this code scrap, we characterize the work `generate_iss_map()`. This work acknowledges the scope and longitude arrangements of the ISS as inputs and continues to form an intelligent world outline, centered around the ISS's area. We incorporate a marker onto the map, accompanied by a tooltip and a popup that provide information about the ISS. Finally, we save the map as an HTML file named `iss_location.html`.
To observe the ISS's location on the map, simply open the `iss_location.html` file in your preferred web browser.
Bonus: Automating ISS Tracking
For real−time ISS tracking, we can devise a simple loop that fetches the ISS location data at regular intervals and subsequently updates the map accordingly.
import time while True: iss_latitude, iss_longitude = acquire_iss_location() print(f"ISS's present location: Latitude: {iss_latitude}, Longitude: {iss_longitude}") iss_map = generate_iss_map(iss_latitude, iss_longitude) iss_map.save("iss_location.html") time.sleep(60)
In this specific illustration, we utilize a `while` loop to ceaselessly recover the ISS's area information each 60 seconds, guaranteeing that the outline remains up to date. In any case, it is fundamental to work out caution when running this loop inconclusively, because it may expend a considerable sum of system resources. It is recommended to implement a stopping condition or a user interrupt mechanism.
The output displayed in the terminal will showcase the ISS's current location in latitude and longitude format:
ISS's present location: Latitude: -51.4142, Longitude: -179.8206

Kindly note that the actual latitude and longitude values will differ depending on the ISS's real−time location at the moment the script is executed.
Conclusion
In conclusion, this article has provided a comprehensive demonstration of how Python can be harnessed to track the International Space Station. By leveraging Open Notify's ISS API and the versatile `folium` library, we were able to retrieve the ISS's location data in the form of latitude and longitude coordinates and effectively visualize its position on an interactive world map. Engaging in such a project not only enhances our understanding of the ISS and its movements but also serves as an opportunity to sharpen our Python programming skills while working with APIs and interactive maps.