stplanpy.acs module

The functions in this module can be used to import American community survey (ACS) origin-destination (OD) data into Pandas. The origin-destination flow data can be found on the website of the American Association of State Highway and Transportation Officials (AASHTO) through their Census Transportation Planning Products Program (CTPP). Use “Means of transportation (18) (Workers 16 years and over)” data under Part3: flows. Select Download format: Comma-delimited ASCII format (*.csv), Data format: List format, and Remove empty rows.

stplanpy.acs.clean_acs(fd: geopandas.geodataframe.GeoDataFrame, returns=False, groups=True, home=True, reduced=True, error=True) geopandas.geodataframe.GeoDataFrame

Clean up and organize ACS flow data.

American Community Survey (ACS) data has information on many modes of transportation and their error margins. This function provides various options to simplify this data and to reduce and combine various modes of transportation.

Parameters
  • returns (bool, defaults to False) – Add duplicate data with switched origin and destination codes

  • groups (bool, defaults to True) – Create an active transportation group (walk and bike), transit group (bus, streetcar, subway, railroad, and ferry), and a carpool group (car_2p, car_3p, car_4p, car_5p, and car_7p).

  • home (bool, defaults to True) – People working from home do not travel. Subtract home from all

  • reduced (bool, defaults to True) – Only keep all, home, walk, bike, and sov, groups (if True).

  • error (bool, defaults to True) – Keep the error data.

Returns

Cleaned up GeoDataFrame with origin-destination data broken down by mode

Return type

geopandas.GeoDataFrame

See also

read_acs

Examples

An example data file, “od_data.csv”, can be downloaded from github.

from stplanpy import acs

flow_data = acs.read_acs("od_data.csv")
flow_data = flow_data.clean_acs()
stplanpy.acs.read_acs(file_name, crs='EPSG:6933') geopandas.geodataframe.GeoDataFrame

Import ACS origin-destination data.

This function imports ACS origin-destination (OD) data into a GeoPandas GeoDataFrame. In the output GeoDataFrame there is one row per origin-destination pair. The column names and their ACS definitions are shown in the table below. For each column name there is an additional column with the margin of error. E.g. in addition to “all” there is a column “all_error”. The geometry column value is None.

Column Name

ACS description

orig_taz

RESIDENCE

dest_taz

WORKPLACE

all

Total, means of transportation

sov

Car, truck, or van – Drove alone

car_2p

Car, truck, or van – In a 2-person carpool

car_3p

Car, truck, or van – In a 3-person carpool

car_4p

Car, truck, or van – In a 4-person carpool

car_5p

Car, truck, or van – In a 5-or-6-person carpool

car_7p

Car, truck, or van – In a 7-or-more-person carpool

bus

Bus or trolley bus

streetcar

Streetcar or trolley car

subway

Subway or elevated

railroad

Railroad

ferry

Ferryboat

bike

Bicycle

walk

Walked

taxi

Taxicab

motorcycle

Motorcycle

other

Other method

home

Worked at home

auto

Auto

Parameters
  • file_name (str) – Name and path of an ACS csv file.

  • crs (str, defaults to "EPSG:6933") – The coordinate reference system (crs) of the output GeoDataFrame. The default value is “EPSG:6933”.

Returns

GeoDataFrame with origin destination data broken down by mode

Return type

geopandas.GeoDataFrame

See also

clean_acs

Examples

An example data file, “od_data.csv”, can be downloaded from github.

from stplanpy import acs

flow_data = acs.read_acs("od_data.csv")