Skip to content

Instantly share code, notes, and snippets.

@danhammer
Last active August 29, 2015 14:15
Show Gist options
  • Save danhammer/7d844482de9a42aba185 to your computer and use it in GitHub Desktop.
Save danhammer/7d844482de9a42aba185 to your computer and use it in GitHub Desktop.
quick script to show earth imagery in python
import requests
from StringIO import StringIO
from pprint import pprint
from PIL import Image
from numpy import array
base = "https://api.data.gov/nasa/planetary/earth"
payload = {
"lon": -122.066133,
"lat": 37.419109,
"size": "large",
"begin": "2014-07-01",
"end": "2014-09-01",
"api_key": "DEMO_KEY"
}
res = requests.get(base, params=payload)
pprint(res.json())
url = res.json()['2014-07-08']
img_string = requests.get(url)
img = Image.open(StringIO(img_string.content))
img.show()
print array(img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment