A small example package
Project description
CensusAPI
Implementation of US Census API calls in form of a python library.
CensusAPI allows to output an augmented geojson file containing census information at the US census tract block level given a geojson file in the US.
Requirements
Key
Obtain a key from http://api.census.gov/data/key_signup.html to acess the Census dataset
and place it in a .env' file: secretKey = Yourkey
Install
See the requirements.txt for all the packages.
census==0.8.19censusgeocode==0.5.2geopandas==0.9.0pandas==1.5.1
Usage
Defined in censusgf.py.
add_census_to_geojson: Returns a geojson with columns containing Census Tract Level Data regarding building tract level ownership, population and income.
Parameters:
in_pth: str. The file location of the geojson building file.out_pth: str. The file location in which to save the augmented file.key: str. The 40 digit text string. Can be obtained from the US Census site.census_variables: tuple[str]. Default = None. An optional tuple of strings identifying ACS 5 Census variables to augment the dataframe. If custom_variables is not specified the function will return an augmented geojson with default columns.
add_census_to_geojson_df: Returns a geojson with additional columns containing Census Tract Level Data regarding building tract level ownership, population and income.
Parameters:
df: GeoDataFrame. The input geodataframe.key: str. The 40 digit text string. Can be obtained from the US Census site.census_variables: tuple[str]. Default = None. An optional tuple of strings identifying ACS 5 Census variables to augment the dataframe. If custom_variables is not specified the function will return an augmented geojson with default columns.
Default Census Variables:
Default variables used to augment the geojson are specified below. They are taken from the ACS 5, 2020 dataset. Default variables can be found in the Detailed Tables:
| Census Variable | Readable Column Name | Variable Description |
|---|---|---|
| B01003_001E | TotPop | Total Population |
| B25003_003E | RentOcc | Renter occupied |
| B25003_002E | OwnOcc | Owner Occupied |
| B25121_001E | Income | Household income in the past 12 months (in 2020 inflation-adjusted dollars) by value |
| B25121_002E | less10k | Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!Less than $10,000 |
| B25121_017E | 10to20k | Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!$10,000 to $19,999 |
| B25121_032E | 20to35k | Estimate!!Total:!!Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!$20,000 to $34,999 |
| B25121_047E | 35to50k | Estimate!!Total:!!Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!$35,000 to $49,999 |
| B25121_062E | 50to75k | Estimate!!Total:!!Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!$50,000 to $74,999 |
| B25121_077E | 75to100k | Estimate!!Total:!!Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!$75,000 to $99,999 |
| B25121_092E | more100k | Estimate!!Total:!!Household income the past 12 months (in 2020 inflation-adjusted dollars) --!!$100,000 or more |
Example
Example can be found in example.py.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geocensusapi-0.0.2.tar.gz.
File metadata
- Download URL: geocensusapi-0.0.2.tar.gz
- Upload date:
- Size: 732.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1624d5158d909f802147836c17ac71fe33d8d93e65634e85aa65312124ff3990
|
|
| MD5 |
46e94c74432db39ccd3241d5be393b64
|
|
| BLAKE2b-256 |
ef6988f3bff8539a0aba56c9cd3ebd6969b2553ece570bf161e4374689a099a5
|
File details
Details for the file geocensusapi-0.0.2-py3-none-any.whl.
File metadata
- Download URL: geocensusapi-0.0.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bd7148beda6a582122075c6c3c740d4ba08f45e696e0b9c3733ce1f822600ba
|
|
| MD5 |
7f4fa6466ff03d720477f11e74db2b19
|
|
| BLAKE2b-256 |
1dee394c13bdeb54c17b657fe1fe7432a95d28f16c6034f8e049b7f9bbc4df52
|