Introducción.

Pagina donde se obtine la latitud y longitud de la estacion 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.

Por sduro