Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
Last active April 23, 2022 16:14
Show Gist options
  • Save CodeMaster7000/ebb0c5b1643f8e93376487d55367297d to your computer and use it in GitHub Desktop.
Save CodeMaster7000/ebb0c5b1643f8e93376487d55367297d to your computer and use it in GitHub Desktop.
A program which locates the International Space Station, maps it and determines your exact latitude and longitude. Run 'ISS Locator.py' in a terminal if you have Python 3 (you must have the json, urllib.request, webbrowser and geocoder modules installed).
import json
import turtle
import urllib.request
import time
import webbrowser
import geocoder
url = "http://api.open-notify.org/astros.json"
response = urllib.request.urlopen(url)
result = json.loads(response.read())
file = open("iss.txt", "w")
file.write("There are currently " +
# prints number of astronauts
str(result["number"]) + " astronauts on the ISS: \n\n")
people = result["people"]
for p in people:
file.write(p['name'] + " - on board" + "\n")
g = geocoder.ip('me')
file.write("\nYour current latitude , longitude is: " + str(g.latlng))
file.close()
webbrowser.open("iss.txt")
screen = turtle.Screen()
screen.setup(1280, 720)
screen.setworldcoordinates(-180, -90, 180, 90)
screen.bgpic("images/map.gif")
screen.register_shape("images\iss.gif")
iss = turtle.Turtle()
iss.shape("images\iss.gif")
iss.setheading(45)
iss.penup()
while True:
url = "http://api.open-notify.org/iss-now.json"
response = urllib.request.urlopen(url)
result = json.loads(response.read())
location = result["iss_position"]
lat = location['latitude']
lon = location['longitude']
lat = float(lat)
lon = float(lon)
print("\nLatitude: " + str(lat))
print("\nLongitude: " + str(lon))
iss.goto(lon, lat)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment