Where is the International Space Station? (Python)

Now that I know how to use images in Python I’ve tackled the “Where is the space station?” lesson of Code Club projects as a) I will be teaching the lesson at some point and its always good to practise the lesson before teaching it and b) I want to make it work using Python 3 on my Mac and not via Trinket (not there is is anything wrong with Trinket, it is a cool website!).

Code Club do offer a version of the files for offline use, but I prefer trying to figure out what needs changing/getting it to work myself instead of relying on others work as I think I learn better that way.

I’ve modified the Python so that it shows the current location of the International Space Station (ISS) and when it will pass over Manchester, United Kingdom:




#Original material at https://codeclubprojects.org/en-GB/python/iss/

#import required libraries

import json,turtle,urllib.request,time

#opens JSON file containing ISS crew information

url = ‘http://api.open-notify.org/astros.json’

response = urllib.request.urlopen(url)

result = json.loads(response.read())

#opens JSON file containing ISS location information

url2 = ‘http://api.open-notify.org/iss-now.json’

response2 = urllib.request.urlopen(url2)

result2 = json.loads(response2.read())

#prints information on who is on the ISS

print(‘People in space:’, result[‘number’])

people = result[‘people’]

for p in people:


#collects information from location JSON

location = result2[‘iss_position’]

lat = location[‘latitude’]

lat = float(lat)

lon = location[‘longitude’]

lon = float(lon)

print(‘ISS current location:’)



#shows a map of planet Earth

screen = turtle.Screen()

screen.setup(720, 360)

screen.setworldcoordinates(-180, -90, 180, 90)


#creates a Turtle for ISS


iss = turtle.Turtle()



#set location for ISS turtle


iss.goto(lon, lat)

#set marker location for Manchester, UK

lat_man = 53.483959

lon_man = -2.244644

location_man = turtle.Turtle()






#when will ISS pass over Manchester, UK

url_man = ‘http://api.open-notify.org/iss-pass.json?lat=53.48&lon=-2.244’

response_man = urllib.request.urlopen(url_man)

result_man = json.loads(response_man.read())

over_man = result_man[‘response’][1][‘risetime’]

#print on map when ISS will pass over Manchester, UK

style = (‘Arial’,6,’bold’)



Original Code Club project:


My GitHub containing the relevant files:





Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.