stplanpy.stats module¶
The helper functions in this module print different statistics to screen. These can be used as input for, for example, the health economic assessment tool (HEAT) for walking and for cycling 2.
- stplanpy.stats.carpool(fd: geopandas.geodataframe.GeoDataFrame)¶
Print how may people carpool
This function prints how many people carpool or drive a single occupancy vehicle (SOV). The whole GeoDataFrame is used to compute these numbers. To limit the scope of the calculation one can use the
to()
,frm()
, andto_frm()
functions. If theclean_acs()
function is used, set reduced=False.See also
Examples
The example data files: “od_data.csv”, “tl_2011_06_taz10.zip”, and “tl_2020_06_place.zip”, can be downloaded from github.
from stplanpy import acs from stplanpy import geo from stplanpy import od from stplanpy import stats # Read origin-destination flow data flow_data = acs.read_acs("od_data.csv") flow_data = flow_data.clean_acs(reduced=False) # San Francisco Bay Area counties counties = ["001", "013", "041", "055", "075", "081", "085", "095", "097"] # Read taz data taz = geo.read_shp("tl_2011_06_taz10.zip") # Rename columns for consistency taz.rename(columns = {"countyfp10":"countyfp", "tazce10":"tazce"}, inplace = True) # Filter on county codes taz = taz[taz["countyfp"].isin(counties)] # Place code East Palo Alto places = ["20956"] # Read place data place = geo.read_shp("tl_2020_06_place.zip") # Keep only East Palo Alto place = place[place["placefp"].isin(places)] # Compute which taz lay inside a place and which part taz = taz.in_place(place) # Add county and place codes to data frame. flow_data = flow_data.orig_dest(taz) # Select origin-destination data to East Palo Alto flow_data = flow_data.to("20956") # Show carpool statistics flow_data.carpool()
- stplanpy.stats.mode_km(fd: geopandas.geodataframe.GeoDataFrame, modes=['walk', 'bike', 'sov'])¶
Print daily kilometers per mode
This function prints both total daily kilometers per mode and daily kilometers per mode per person to screen for the modes of transportation given in modes. The default modes are “walk”, “bike”, and “sov”. The whole GeoDataFrame is used to compute the daily kilometers. To limit the scope of the calculation one can use the
to()
,frm()
, andto_frm()
functions.- Parameters
modes (list of str, defaults to ["walk", "bike", "sov"]) – Default list of modes of transportation to show the mode share for. Defaults to [“walk”, “bike”, “sov”].
See also
Examples
The example data files: “od_data.csv”, “tl_2011_06_taz10.zip”, and “tl_2020_06_place.zip”, can be downloaded from github.
from stplanpy import acs from stplanpy import geo from stplanpy import od from stplanpy import stats # Read origin-destination flow data flow_data = acs.read_acs("od_data.csv") flow_data = flow_data.clean_acs() # San Francisco Bay Area counties counties = ["001", "013", "041", "055", "075", "081", "085", "095", "097"] # Read taz data taz = geo.read_shp("tl_2011_06_taz10.zip") # Rename columns for consistency taz.rename(columns = {"countyfp10":"countyfp", "tazce10":"tazce"}, inplace = True) # Filter on county codes taz = taz[taz["countyfp"].isin(counties)] # Compute centroids taz_cent = taz.cent() # Place code East Palo Alto places = ["20956"] # Read place data place = geo.read_shp("tl_2020_06_place.zip") # Keep only East Palo Alto place = place[place["placefp"].isin(places)] # Compute which taz lay inside a place and which part taz = taz.in_place(place) # Add county and place codes to data frame. flow_data = flow_data.orig_dest(taz) # Select origin-destination data to East Palo Alto flow_data = flow_data.to("20956") # Compute origin-destination lines, and distances flow_data["geometry"] = flow_data.od_lines(taz_cent) flow_data["distance"] = flow_data.distances() # Show kilometers per mode statistics flow_data.mode_km()
- stplanpy.stats.mode_stats(fd: geopandas.geodataframe.GeoDataFrame, modes=['walk', 'bike', 'sov'])¶
Print mode statistics
This function prints mode share and number of workers to screen for the modes of transportation given in modes. The default modes are “walk”, “bike”, and “sov”. The whole GeoDataFrame is used to compute the daily kilometers. To limit the scope of the calculation one can use the
to()
,frm()
, andto_frm()
functions.- Parameters
modes (list of str, defaults to ["walk", "bike", "sov"]) – Default list of modes of transportation to show the mode share for. Defaults to [“walk”, “bike”, “sov”].
See also
Examples
The example data files: “od_data.csv”, “tl_2011_06_taz10.zip”, and “tl_2020_06_place.zip”, can be downloaded from github.
from stplanpy import acs from stplanpy import geo from stplanpy import od from stplanpy import stats # Read origin-destination flow data flow_data = acs.read_acs("od_data.csv") flow_data = flow_data.clean_acs() # San Francisco Bay Area counties counties = ["001", "013", "041", "055", "075", "081", "085", "095", "097"] # Read taz data taz = geo.read_shp("tl_2011_06_taz10.zip") # Rename columns for consistency taz.rename(columns = {"countyfp10":"countyfp", "tazce10":"tazce"}, inplace = True) # Filter on county codes taz = taz[taz["countyfp"].isin(counties)] # Place code East Palo Alto places = ["20956"] # Read place data place = geo.read_shp("tl_2020_06_place.zip") # Keep only East Palo Alto place = place[place["placefp"].isin(places)] # Compute which taz lay inside a place and which part taz = taz.in_place(place) # Add county and place codes to data frame. flow_data = flow_data.orig_dest(taz) # Select origin-destination data to East Palo Alto flow_data = flow_data.to("20956") # Show mode statistics flow_data.mode_stats()
- stplanpy.stats.occupancy(fd: geopandas.geodataframe.GeoDataFrame)¶
Print average vehicle occupancy rate
This function prints the average vehicle occupancy rate. For “Car, truck, or van – In a 5-or-6-person carpool” an occupancy of 5.5 is assumed and for “Car, truck, or van – In a 7-or-more-person carpool” an occupancy of 7. The whole DataFrame is used to compute this number. To limit the scope of the calculation one can use the
to()
,frm()
, andto_frm()
functions. If theclean_acs()
function is used, set reduced=False.See also
Examples
The example data files: “od_data.csv”, “tl_2011_06_taz10.zip”, and “tl_2020_06_place.zip”, can be downloaded from github.
from stplanpy import acs from stplanpy import geo from stplanpy import od from stplanpy import stats # Read origin-destination flow data flow_data = acs.read_acs("od_data.csv") flow_data = flow_data.clean_acs(reduced=False) # San Francisco Bay Area counties counties = ["001", "013", "041", "055", "075", "081", "085", "095", "097"] # Read taz data taz = geo.read_shp("tl_2011_06_taz10.zip") # Rename columns for consistency taz.rename(columns = {"countyfp10":"countyfp", "tazce10":"tazce"}, inplace = True) # Filter on county codes taz = taz[taz["countyfp"].isin(counties)] # Place code East Palo Alto places = ["20956"] # Read place data place = geo.read_shp("tl_2020_06_place.zip") # Keep only East Palo Alto place = place[place["placefp"].isin(places)] # Compute which taz lay inside a place and which part taz = taz.in_place(place) # Add county and place codes to data frame. flow_data = flow_data.orig_dest(taz) # Select origin-destination data to East Palo Alto flow_data = flow_data.to("20956") # Show average vehicle occupancy flow_data.occupancy()
References
- 2
Sonja Kahlmeier, Thomas Gőtschi, Nick Cavill, et al., “Health economic assessment tool (HEAT) for walking and for cycling.”, World Health Organization, Regional Office for Europe, 2017, url:https://www.heatwalkingcycling.org