Getting Started#
In this section we describe the basic structure of traccess and how you can use it to quickly compute access and equity metrics.
There are two main types of objects in Traccess: data objects and computer
objects. Data objects hold specific types of information and data, such as the
Demographic object which holds information on various
populations. Computer objects use these data sets to compute metrics of access
(AccessComputer) and equity
(EquityComputer).
Computing Access#
To compute access, you will at minimum need to define a
Supply dataset and a Cost
matrix. If you want a very simple example of how those look, you can download a
small example supply file and
example cost file.
Loading from CSV#
Here’s a minimum working example, where we load in two CSV files, specify the
columns which indicate origin and destination zones, and create an
AccessComputer object. We are now ready to compute
access to opportunities.
from traccess import AccessComputer, Cost, Supply
supply = Supply.from_csv("supply.csv", id_column="id")
cost = Cost.from_csv("costs.csv", from_id="o", to_id="d")
ac = AccessComputer(supply, cost)
Note
When you load from a CSV or Parquet file, you can pass along any arguments that you might normally send to Pandas.read_csv() or Pandas.read_parquet(). This is especially useful when you want to specify dtypes for your ID columns.
Note
The dataframe associated with each object is stored in <object>.data. So for example, supply.data returns the dataframe containing supply information.
Passing DataFrames Directly#
If you already have a pandas DataFrame object you can pass it directly to the constructor:
supply = Supply(dataframe, id_column="origin_id")
Compute Accecss Metrics#
Now that you have the appropriate data loaded and computer object set, you can compute any number of access metrics:
second_closest = ac.cost_to_closest(cost_column="c", supply_columns=["oj2"], n=2)
cutoff45 = ac.cumulative_cutoff(cost_column=["c"], cutoffs=[45])
Each of these produces an Access object which can
be fed into an EquityComputer for further analysis,
or the data can be accessed directly using <Access>.data.