def getFiveDigitZCTAs(depends_on = 'http://www.census.gov/geo/www/cob/z52000.html',creates = root + 'FiveDigitZCTAs/'): MakeDir(creates) wget(depends_on,creates + '__Index.html') Soup = BS.BeautifulSoup(open(creates + '__Index.html')) A = [(Contents(x.findParent()).split(' - ')[0].strip(),str(dict(x.attrs)['href'])) for x in Soup.findAll('a') if '_shp' in str(x)] for (name,url) in A: print 'Downloading', name wget('http://www.census.gov' + url, creates + url.split('/')[-1]) os.system('cd ' + creates + ' ; unzip ' + url.split('/')[-1])
def getStates(depends_on = 'http://www.census.gov/geo/cob/bdy/st/st00shp/st99_d00_shp.zip', creates = root + 'States/'): MakeDir(creates) wget(depends_on,creates + 'st99_d00_shp.zip') os.system('cd ' + creates + ' ; unzip st99_d00_shp.zip')
def getCounties(depends_on = 'http://www.census.gov/geo/cob/bdy/co/co00shp/co99_d00_shp.zip', creates = root + 'Counties/'): MakeDir(creates) wget(depends_on,creates + 'co99_d00_shp.zip') os.system('cd ' + creates + ' ; unzip co99_d00_shp.zip')
def getMSA(depends_on = 'http://www.census.gov/geo/www/cob/mmsa2003.html', creates = root + 'MSA/'): MakeDir(creates) for x in ['cs99_03c_shp.zip','cb99_03c_shp.zip','md99_03c_shp.zip']: wget('http://www.census.gov/geo/cob/bdy/metroarea/2003/shp/' + x, creates + x) os.system('cd ' + creates + ' ; unzip ' + x)
def getCensusRegions(depends_on = 'http://www.census.gov/geo/cob/bdy/rg/rg99_d00_shp.zip', creates = root + 'CensusRegions/'): MakeDir(creates) wget(depends_on,creates + 'rg99_d00_shp.zip') os.system('cd ' + creates + ' ; unzip rg99_d00_shp.zip')