def download_tract_shapefile(state_fips: str, resolution: str) -> None: target_folder = src_path('cartographic_shapes') ct_url = ('http://www2.census.gov/geo/' + f'tiger/GENZ2010/gz_2010_{state_fips}_140_00_{resolution}.zip') zip_file_name = os.path.split(ct_url)[1] zip_file_path = os.path.join(target_folder, zip_file_name) if os.path.isfile(zip_file_path): print(f'{zip_file_name} already on disk') return else: urllib.request.urlretrieve(ct_url, zip_file_path)
def carto_shapes_src_path(filename: str) -> str: return src_path('cartographic_boundaries', filename)
def files_target_path(year: int, f_name: str) -> str: return src_path('tigerline', 'BLOCK', f'{year}', f_name)
def _blocks_zip_path(state_fips: str) -> str: zip_path = src_path('census', 'shapefile_block', f'tl_2010_{state_fips}_tabblock10.zip') return zip_path
def _blocks_shape_path(state_fips: str) -> str: shp_path = src_path('census', 'shapefile_block', f'tl_2010_{state_fips}_tabblock10.shp') return shp_path
def _tracts_zip_path(state_fips: str) -> str: zip_path = src_path('census', 'census_tract_shapefiles_2010', 'zipped', f'gz_2010_{state_fips}_140_00_500k.zip') return zip_path
def year_path_root(year: int) -> str: return src_path('tigerline', 'ROADS', f'{year}')
def zip_path(year: int) -> str: zipname = f'tl_{year}_us_county.zip' zippath = src_path('tigerline', 'COUNTY', f'{year}', zipname) return zippath
def _download(year: int) -> None: ftp = ftp_connection(year) ftp.cwd('COUNTY') fname = ftp.nlst()[0] get_binary(fname, src_path('tigerline', 'COUNTY', f'{year}', fname), ftp) ftp.close()