Last active
August 29, 2015 14:15
-
-
Save danhammer/7d844482de9a42aba185 to your computer and use it in GitHub Desktop.
quick script to show earth imagery in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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