Skip to main content

A Python package to make it easier to visualize Census data.

Project description

censusviz -- map Census data

This package helps users more easily visualize maps using Census Population Estimate API and the Census Cartographic GeoJSON boundary files. It transforms GeoJSON files into easy to work with GeoPandas.GeoDataFrame and plot choropleth maps.

How To Install

Please install and import the censusviz package using the following commands.

pip install censusviz

After installing via pip, please import the package to use on your Python IDE.

from censusviz import censusviz

Usage

Find Available Geo Parameters

The list_geoparams function returns a table from the Census' Github telling users which GeoJSON files are available by Year and geography area type.

Parameters (optional):

  • year: A string value of the year you would like to recall. %Y. Optional and will return a subset of table if specified.
censusviz.list_geoparam()

censusviz.list_geoparam(year = 2010)

Return a Geopandas dataframe

The get_geocen_df function returns a geopandas.GeoDataFrame of Census cartographic files.

Parameters:

  • quality: a string value of the resolution of the GeoJSON file. The available resolutions are 20m, 5m, and 500k.
  • year: a string value of the year you would like to recall. %Y. Year availables: 1990, 2000, 2010, 2012-2019.
  • area_type: a stringe value of the geography area value you would like to specify.
geocenpy.get_geocen_df(quality = "20m", year = "2010", area_type= "county")

Return State Identifiers

The get_state_ids function returns a pandas.DataFrame of state-related federal codes such as FIPS and USPS codes.

Parameters:

  • state_initials: a string value of the officially recognized state abbreviation.
censusviz.get_state_ids(state_initials = "OR")

censusviz.get_state_ids(state_initials = "NY")

Plot Cartographic shapes

The get_geocen_plot function returns a matplotlib.pyplot.plot of a specified cartographic area by year, area type and resolution quality.

Parameters

  • quality: a string value of the resolution of the GeoJSON file. The available resolutions are 20m, 5m, and 500k.
  • year: a string value of the year you would like to recall. %Y. Years available: 1990, 2000, 2010, 2012-2019.
  • area_type: a string value of the geography area value you would like to specify.
  • boundaries: a boolean value that if True returns only the outline/boundaries of the area specified and if false returns the whole area filled in.
censusviz.get_geocen_plot(quality ="20m", year="2010", area_type="county", boundaries=False)

Return Population Data with Map

The get_pop function returns a choropleth map in matplotlib.pyplot.plot format or a geopandas.GeoDataFrame of the U.S. population by year and geometric boundaries. It utilizes the U.S. Census Bureau Population Estimate API and the Census GeoJSON database on GitHub.

Parameters

  • api_key: a private api key provided by the U.S. Census Bureau. https://www.census.gov/data/developers/data-sets/popest-popproj/popest.html
  • year: a string value of the year you would like to recall. %Y. Year availables: 2015-2019.
  • map: a boolean value that if True returns matplotlib.pyplot.plot of the area specified and if false returns a geopandas.GeoDataFrame of the same values.
censusviz.get_pop(api_key = my_api_key, year="2018", map = False)

censusviz.get_pop(api_key = my_api_key, year="2019", map = True)

Return Population Data with Map (By Region)

The get_region_pop function function returns a choropleth map in matplotlib.pyplot.plot format or a geopandas.GeoDataFrame of the U.S. population by year and region. It utilizes the U.S. Census Bureau Population Estimate API and the Census GeoJSON database on GitHub.

Parameters

  • api_key: a private api key provided by the U.S. Census Bureau. https://www.census.gov/data/developers/data-sets/popest-popproj/popest.html
  • year: a string value of the year you would like to recall. %Y. Year availables: 2018-2019.
  • map: a boolean value that if True returns matplotlib.pyplot.plot of the area specified and if false returns a geopandas.GeoDataFrame for the same values.
censusviz.get_region_pop(api_key = my_api_key, year="2016", map = False)

censusviz.get_region_pop(api_key = my_api_key, year="2019", map = True)

Return Population Data with Map (By State)

The get_state_pop function returns a choropleth map in matplotlib.pyplot.plot format or a geopandas.GeoDataFrame of the U.S. population by year and state. It utlizes the U.S. Census Bureau Population Estimate API and the Census GeoJSON database on GitHub.

Parameters

  • api_key: a private api key provided by the U.S. Census Bureau. https://www.census.gov/data/developers/data-sets/popest-popproj/popest.html
  • year: a string value of the year you would like to recall. %Y. Year availables: 2018-2019.
  • state_fip: a string value of the state Federal Information Processing Standard state code.
  • map: a boolean value that if True returns matplotlib.pyplot.plot of the area specified and if false returns a geopandas.GeoDataFrame for the same values.
censusviz.get_state_pop(api_key = my_api_key, year="2016", state_fip = "15", map = False)

censusviz.get_state_pop(api_key = my_api_key, year="2019", state_fip = "29", map = True)

Return Housing Unit Estimation Data with Map

The get_house_est returns a choropleth map in matplotlib.pyplot.plot format or a geopandas.GeoDataFrame of the U.S. housing estimates by year. It utlizes the U.S. Census Bureau Housing Unit Estimate API and the Census GeoJSON database on GitHub.

Parameters

  • api_key: a private api key provided by the U.S. Census Bureau. https://www.census.gov/data/developers/data-sets/popest-popproj/popest.html
  • year: a string value of the year you would like to recall. %Y. Year availables: 2018-2019.
  • map: a boolean value that if True returns matplotlib.pyplot.plot of the area specified and if false returns a geopandas.GeoDataFrame for the same values.
censusviz.get_house_est(api_key = my_api_key, year="2018", map = False)

censusviz.get_house_est(api_key = my_api_key, year="2019", map = True)

Dependencies

Documentation

The official documentation is hosted on Read the Docs: https://censusviz.readthedocs.io/en/latest/

Contributors

We welcome and recognize all contributions. You can see a list of current contributors in the contributors tab.

Credits

This package was created with Cookiecutter and the UBC-MDS/cookiecutter-ubc-mds project template, modified from the pyOpenSci/cookiecutter-pyopensci project template and the audreyr/cookiecutter-pypackage.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

censusviz-0.1.7.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

censusviz-0.1.7-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page