Skip to content

Instantly share code, notes, and snippets.

@notlion
Created November 27, 2010 18:57
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 notlion/718161 to your computer and use it in GitHub Desktop.
Save notlion/718161 to your computer and use it in GitHub Desktop.
SRTM Elevation Image Grabber
import commands
import os
baseUrl = "http://hypersphere.telascience.org/elevation/cgiar_srtm_v4/tiff/zip/"
for x in range(1,73):
for y in range(1,25):
zipname = "srtm_%02d_%02d.ZIP" % (x, y)
tifname = "srtm_%02d_%02d.TIF" % (x, y)
if os.path.exists(tifname):
print tifname + " exists, skipping."
else:
print "Downloading tile [ %s, %s ]" % (x, y)
print "\tfrom %s%s" % (baseUrl, zipname)
out = commands.getoutput("curl %s%s -O" % (baseUrl, zipname))
head = commands.getoutput("head -c 9 " + zipname)
if head == "<!DOCTYPE":
print "NO TILE :(\n"
commands.getoutput("rm " + zipname)
else:
print "TILE OK :)\n"
commands.getoutput("unzip -o " + zipname)
commands.getoutput("rm " + zipname)
commands.getoutput("rm README.TXT")
print "ALL DONE!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment