Skip to content

Instantly share code, notes, and snippets.

@natronics
Created October 18, 2011 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save natronics/1294666 to your computer and use it in GitHub Desktop.
Save natronics/1294666 to your computer and use it in GitHub Desktop.
Get a MODIS image from every day of the year using one of NASA's predefined subsets
#!/usr/bin/env python
# Get the MODIS image from every day of the year using one of NASA's predefined
# subsets
import urllib
import time
baseurl = 'http://rapidfire.sci.gsfc.nasa.gov/subsets/?subset='
subset = 'USA1' # Pacific Northwest
resolution = '250m' # 250 meters per pixel
satellite = 'terra' # EOS AM-1
year = '2010'
url = baseurl + subset
url = url + '.' + year + '%03d' # date code
url = url + '.' + satellite
url = url + '.' + resolution
url = url + '.jpg'
def getimage(day):
modis = url % day
fname = '250m/%04d.jpg' % day
# Get the image, write it to file fname
urllib.urlretrieve(modis, fname)
# Every Day
for i in range(1,365):
getimage(i)
# Show progress in output
print i
# Wait at least a minute between calls, be nice!
time.sleep(120)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment