Skip to content

Latest commit

 

History

History
37 lines (32 loc) · 2.08 KB

README.md

File metadata and controls

37 lines (32 loc) · 2.08 KB

ZIP-Code Converters

Python functions for using USA ZIP Codes in geospatial processes.

Code style: black

By J. A. Cooper -- https://github.com/cooperjaXC

Overview

Crosswalks for easy python conversions of USA ZIP Codes.

  1. ZIP Codes → ZCTAs
  1. ZIP Codes → ZCTAs
  • Input
    • ZCTAs (string)
  • Outputs:
    • Each corresponding 5 digit postal Zip Codes (list)

Operates with both individual ZIP Codes and pandas dataframes. Compatible with both US Census year 2010 and 2020 (default) ZCTAs.

Key Functions

  • zip_code_crosswalk - Takes a (1) postal ZIP Code and transforms it into a Zip Code Tract Area (ZCTAs), the US Census-defined polygonal region for a ZIP Code. Compatible with both 2010 and 2020 ZCTAs.
  • df_zip_crosswalk - Takes a Pandas Dataframe with a ZIP-Code field and returns a ZCTA field using the crosswalk function.
  • reverse_zcta_crosswalk - Takes a (1) Zip Code Tract Area (ZCTAs) and returns all its associated postal ZIP Codes. Compatible with both 2010 and 2020 ZCTAs.
  • df_reverse_zcta_crosswalk - Takes a Pandas Dataframe with a ZCTA field and returns a field with a list of associated ZIP-Codes. Uses the reverse crosswalk function.
  • lat_lon_centroid - Takes a (1) postal ZIP Code and returns its ZCTA's spatial coordinates in a [latitude, longitude] format based on US Census TIGER shapefiles. Compatible with both 2010 and 2020 ZCTAs.
  • df_latlon_centroids - Takes a Pandas Dataframe with a ZIP-Code field and returns fields with the ZCTA's central latitude and longitude coordinates using the centroid function.