Skip to content

Instantly share code, notes, and snippets.

@palewire
Created September 9, 2012 23:15
Show Gist options
  • Save palewire/3687880 to your computer and use it in GitHub Desktop.
Save palewire/3687880 to your computer and use it in GitHub Desktop.
Download elevation data for the state of California from the USGS's NED system
"""
Download elevation data for California from with USGS's NED data
"""
import os
import urllib
CALIFORNIA_TILES = {
'42120': 'n42w120_13',
'42121': 'n42w121_13',
'42122': 'n42w122_13',
'42123': 'n42w123_13',
'42124': 'n42w124_13',
'42125': 'n42w125_13',
'37116': 'n37w116_13',
'37117': 'n37w117_13',
'37118': 'n37w118_13',
'37119': 'n37w119_13',
'37120': 'n37w120_13',
'34115': 'n34w115_13',
'34116': 'n34w116_13',
'34117': 'n34w117_13',
'34118': 'n34w118_13',
'34119': 'n34w119_13',
'34120': 'n34w120_13',
'34121': 'n34w121_13',
'40120': 'n40w120_13',
'40121': 'n40w121_13',
'40122': 'n40w122_13',
'40123': 'n40w123_13',
'40124': 'n40w124_13',
'40125': 'n40w125_13',
'37121': 'n37w121_13',
'39123': 'n39w123_13',
'36115': 'n36w115_13',
'36116': 'n36w116_13',
'36117': 'n36w117_13',
'36118': 'n36w118_13',
'36119': 'n36w119_13',
'36120': 'n36w120_13',
'36121': 'n36w121_13',
'36122': 'n36w122_13',
'33115': 'n33w115_13',
'33116': 'n33w116_13',
'33117': 'n33w117_13',
'33118': 'n33w118_13',
'33119': 'n33w119_13',
'39119': 'n39w119_13',
'39120': 'n39w120_13',
'39121': 'n39w121_13',
'39122': 'n39w122_13',
'41120': 'n41w120_13',
'41121': 'n41w121_13',
'41122': 'n41w122_13',
'41123': 'n41w123_13',
'41124': 'n41w124_13',
'41125': 'n41w125_13',
'43120': 'n43w120_13',
'43121': 'n43w121_13',
'43122': 'n43w122_13',
'43123': 'n43w123_13',
'43124': 'n43w124_13',
'43125': 'n43w125_13',
'35115': 'n35w115_13',
'35116': 'n35w116_13',
'35117': 'n35w117_13',
'35118': 'n35w118_13',
'35119': 'n35w119_13',
'35120': 'n35w120_13',
'35121': 'n35w121_13',
'39124': 'n39w124_13',
'37122': 'n37w122_13',
'37123': 'n37w123_13',
'38118': 'n38w118_13',
'38119': 'n38w119_13',
'38120': 'n38w120_13',
'38121': 'n38w121_13',
'38122': 'n38w122_13',
'38123': 'n38w123_13',
'38124': 'n38w124_13',
}
BASE_URL = 'http://gisdata.usgs.gov/TDDS/DownloadFile.php?TYPE=ned3g_zip&ORIG=TNM&FNAME=%(name)s.zip'
DOWNLOAD_PATH = '<your_download_path>'
def download_tile(number, name):
"""
Download a zipped up version of an ArcGRID raster tile from USGS
"""
url = BASE_URL % dict(number=number, name=name.replace("_13", ""))
save_as = os.path.join(DOWNLOAD_PATH, '%s_%s.zip' % (number, name))
if os.path.exists(save_as):
print "Skipping %s because we've already got it" % save_as
return False
else:
print "Retrieving %s" % url
urllib.urlretrieve(url, save_as)
return True
if __name__ == '__main__':
for number, name in CALIFORNIA_TILES.items():
download_tile(number, name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment