Using the Python TRACC Library for Urban Transportation Accessibility Analysis
This article introduces the open‑source Python library TRACC, explains how to install it, prepare destination and travel‑cost data, and walk through a step‑by‑step workflow—including code snippets—to compute potential, passive, and minimum travel‑cost accessibility metrics for urban areas.
As cities grow, transportation accessibility becomes a key indicator for urban development and planning. By analyzing transport networks and destination distributions, we can assess how easily people can reach jobs, services, and other opportunities.
TRACC Overview
TRACC is an open‑source Python library focused on city‑scale accessibility analysis. It combines land‑use data (e.g., jobs, population, shops, medical facilities) with pre‑computed travel costs (e.g., travel time, transit fares) to generate accessibility indicators. Most operations are performed on pandas DataFrames.
The library can compute three types of accessibility:
Potential accessibility: weighted sum of opportunities reachable within a given travel time.
Passive accessibility: weighted sum of population that can reach a location within a given travel time.
Minimum travel‑cost accessibility: the smallest travel cost to reach a set number of opportunities.
Additional features include estimating regional travel costs, filling gaps in travel‑cost matrices using spatial weight matrices, generating impedance functions (cumulative, linear, negative exponential, inverse power), and calculating generalized costs.
Installation
pip install traccData Preparation
Two datasets are required: destination data (e.g., employment counts from LEHD for Boston) and travel‑cost data (e.g., public‑transport travel‑time matrix between zones).
Analysis Workflow
Load data : # Load destination data dfo = tracc.supply( supply_df=pd.read_csv("examples/test_data/boston/destination_employment_lehd.csv"), columns=["block_group_id", "C000"] # C000 = total jobs ) # Load travel‑cost data dft = tracc.costs( pd.read_csv("examples/test_data/boston/transit_time_matrix_8am_30_06_2020.zip", compression='zip') ) dft.data.time = dft.data.time / 60 # convert seconds to minutes
Compute impedance function : dft.impedence_calc( cost_column="time", impedence_func="cumulative", impedence_func_params=45, output_col_name="fCij_c45", prune_output=False )
Set up accessibility object : acc = tracc.accessibility( travelcosts_df=dft.data, supply_df=dfo.data, travelcosts_ids=["o_block", "d_block"], supply_ids="block_group_id" )
Calculate accessibility : dfa = acc.potential( opportunity="C000", impedence="fCij_c45" )
The first five rows of dfa show, for example, that from block group 250056001001 a person can reach 4,061 jobs within a 45‑minute travel time.
<code> o_block A_C000_fCij_c45
---------------------------------
0 250056001001 4061.0
1 250056001002 3960.0
2 250056002021 3608.0
3 250056002022 7845.0
4 250056002023 5124.0
</code>These results can be visualized in Python, QGIS, or any GIS software to map job accessibility across the city, aiding planners and policymakers in optimizing transport resources and improving quality of life.
TRACC provides a powerful, flexible tool for transportation accessibility studies and can be extended for various research purposes.
Python Programming Learning Circle
A global community of Chinese Python developers offering technical articles, columns, original video tutorials, and problem sets. Topics include web full‑stack development, web scraping, data analysis, natural language processing, image processing, machine learning, automated testing, DevOps automation, and big data.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.