Introducció

L’ISS Tracker és una eina que permet rastrejar la posició i la trajectòria en temps real de l’Estació Espacial Internacional (ISS, per les seves sigles en anglès) des de qualsevol lloc del món. L’ISS és un laboratori en òrbita que orbita al voltant de la Terra a una altitud d’aproximadament 400 quilòmetres i a una velocitat de més de 27.000 quilòmetres per hora.

L’ISS Tracker utilitza les dades de posició de l’ISS proporcionades per la NASA i altres organismes espacials per mostrar la ubicació actual de l’estació en un mapa en temps real. També pot proporcionar informació sobre la durada del dia i la nit en la ubicació de l’usuari, així com detalls sobre quan l’ISS serà visible en el cel nocturn i durant quant temps.

A més de ser una eina útil per als entusiastes de l’espai i els observadors d’estrelles, l’ISS Tracker també és una eina important per als astronautes i els equips de control de la missió a terra, ja que els permet monitoritzar la ubicació i la trajectòria de l’ISS en tot moment per garantir la seva seguretat i la dels membres de l’equip a bord.

Página donde se obtiene la latitud y longitud de la estación espacial https://api.wheretheiss.at/v1/satellites/25544

{
"name":"iss",
"id":25544,
"latitude":-49.286361096358,
"longitude":-79.112974058659,
"altitude":435.51955173138,
"velocity":27541.325742835,
"visibility":"daylight",
"footprint":4585.5919346302,
"timestamp":1609618348,
"daynum":2459217.3419907,
"solar_lat":-22.833735560553,
"solar_lon":237.96509928192,
"units":"kilometers"
}

Fuente: https://wheretheiss.at/w/developer

ISSTracker (Version 1)

Having researched trackers there are lots of sites that provide handy APIs to get the current latitude and longitude of the space station.  I settled on using wheretheissis.at as this provided the most comprehensive information I could find in an API.

All the coded needed to do was pull down the JSON provided by the API then parse the data for the values it needed. Below is an extract to show you how this is done

#!/usr/bin/env python3

from urllib.request import urlopen
import json
import time

feed_url="https://api.wheretheiss.at/v1/satellites/25544"

def informacion():
    try:
        jsonFeed = urlopen(feed_url)
        feedData = jsonFeed.read()
        #print feedData
        jsonFeed.close()
        data = json.loads(feedData)
        return data
    except Exception:
        import traceback
        print ("generic exception: " + traceback.format_exc())
 
    return []       
 
#use this method to retrieve from web API
def parseISSDataFeed():
    data = informacion()
    if len(data) == 0:
        return []

    name = data['name']
    lat = data['latitude']
    lng = data['longitude']
    alt = data['altitude']

    return [name, lng, lat, alt]

def main():
        print (parseISSDataFeed())

if __name__ == "__main__":
    while(1):
        time.sleep(1)
        main()

Now to display the ISS.  The visible globe is essentially half of a sphere and so represents 180º in both the latitude (top/bottom or North/South) and longitude (left/right or East/West).  With only 8 pixels that means each LED represents 22.5º of the Earths’ surface.

To display the location of the ISS we take the current lat/long of its position over the Earth and map that to the pixel/LED it falls into.  That’s all well and good when it’s on the “visible” side of the globe in the overlay, but what to do when it goes “behind” our overlay?

Rather than make the ISS “disappear” I opted to still display it but in a different colour so it can be tracked as it reappears on the visible side of our globe.  So now the LED lights up yellow for the visible side of the globe and blue when the ISS passes over the horizon to the rear of the planet.

[wp-osm id=1]

ISS Tracker (versió 2)

Per determinar la posició actual de la ISS en Python, pots utilitzar la llibreria requests per fer una crida a l’API de la NASA que proporciona les dades de posició de l’ISS. Aquí tens un exemple de com fer-ho:

import requests

# URL de l'API que proporciona la posició de l'ISS
url = 'http://api.open-notify.org/iss-now.json'

# Fer la crida a l'API per obtenir les dades de posició de l'ISS
response = requests.get(url)

# Si la crida es va fer amb èxit (codi de resposta HTTP 200)
if response.status_code == 200:
    # Parsejar les dades JSON de la resposta
    data = response.json()

    # Obtenir les coordenades de la posició actual de l'ISS
    latitude = data['iss_position']['latitude']
    longitude = data['iss_position']['longitude']

    # Mostrar la posició actual de l'ISS
    print(f"La posició actual de l'ISS és: {latitude}, {longitude}")
else:
    print("No s'ha pogut obtenir la posició de l'ISS")

Aquest programa fa una crida a l’API de l’ISS Tracker de la NASA i parseja les dades JSON de la resposta per obtenir les coordenades de la posició actual de l’ISS. Finalment, mostra aquesta informació per pantalla. Tingues en compte que aquesta posició és la posició actual en temps real, de manera que si executes el programa en diferents moments, obtindràs diferents coordenades.