Created
November 27, 2010 18:57
-
-
Save notlion/718161 to your computer and use it in GitHub Desktop.
SRTM Elevation Image Grabber
This file contains 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 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