access.Access

class access.Access(demand_df, demand_value, supply_df, supply_value=False, demand_index=True, supply_index=True, cost_df=None, cost_origin=None, cost_dest=None, cost_name=None, neighbor_cost_df=None, neighbor_cost_origin=None, neighbor_cost_dest=None, neighbor_cost_name=None)[source]

Spatial Access Class

Parameters:
demand_dfpandas.DataFrame or geopandas.GeoDataFrame

The origins dataframe, containing a location index and, optionally, a level of demand and geometry.

demand_index{bool, str}

boolean of True indicates that the locations are already on the df index; otherwise the argument is a string containing the name of the column of demand_df that holds the origin ID.

demand_valuestr

is the name of the column of demand that holds the aggregate demand at a location.

supply_dfpandas.DataFrame or geopandas.GeoDataFrame

The origins dataframe, containing a location index and, optionally, level of supply and geometry.

supply_index{bool, str}

boolean of True indicates that the locations are already on the df index; otherwise the argument is a string containing the name of the column of supply_df that holds the origin ID.

supply_value{str, list}

is the name of the column of supply that holds the aggregate supply at a location, or a list of such columns.

cost_dfpandas.DataFrame

This dataframe contains a link from demand to supply locations, and a cost between them.

cost_originstr

The column name of the index locations – this is what will be grouped by.

cost_deststr

The column name of the neighborhing demand locations – this is what goes in the groups.

cost_name{str, list}

The column(s) name of the travel cost(s).

neighbor_cost_dfpandas.DataFrame

This dataframe contains a link from demand to neighbor locations, and a cost between them (running consumer to supplier).

neighbor_cost_originstr

The column name of the origin locations – this is what will be grouped by.

neighbor_cost_deststr

The column name of the destination locations – this is what goes in the groups.

neighbor_cost_name{str, list}

The column name(s) of the travel cost(s).

Attributes:
Accesspandas.DataFrame

All of the calculated access measures.

access_metadatapandas.DataFrame

Lists currently-available measures of access.

cost_metadatapandas.DataFrame

Describes each of the currently-available supply to demand costs.

Methods

append_user_cost(new_cost_df, origin, ...)

Create a user cost, from demand to supply locations.

append_user_cost_neighbors(new_cost_df, ...)

Create a user cost, from supply locations to other supply locations.

create_euclidean_distance([name, threshold, ...])

Calculate the Euclidean distance from demand to supply locations.

create_euclidean_distance_neighbors([name, ...])

Calculate the Euclidean distance among demand locations.

enhanced_two_stage_fca([name, cost, ...])

Calculate the enhanced two-stage floating catchment area access score.

fca_ratio([name, demand_cost, supply_cost, ...])

Calculate the floating catchment area (buffer) ratio access score.

raam([name, cost, supply_values, normalize, ...])

Calculate the rational agent access model.

score(col_dict[, name])

Weighted aggregate of multiple already-calculated, normalized access components.

three_stage_fca([name, cost, supply_values, ...])

Calculate the three-stage floating catchment area access score.

two_stage_fca([name, cost, max_cost, ...])

Calculate the two-stage floating catchment area access score.

weighted_catchment([name, supply_cost, ...])

Calculate the catchment area (buffer) aggregate access score.

__init__(demand_df, demand_value, supply_df, supply_value=False, demand_index=True, supply_index=True, cost_df=None, cost_origin=None, cost_dest=None, cost_name=None, neighbor_cost_df=None, neighbor_cost_origin=None, neighbor_cost_dest=None, neighbor_cost_name=None)[source]

Initialize the class.

Examples

Import the base Access class and Datasets.

>>> from access import Access, Datasets

Load each of the example datasets:

>>> chi_docs_dents   = Datasets.load_data('chi_doc')
>>> chi_population   = Datasets.load_data('chi_pop')
>>> chi_travel_costs = Datasets.load_data('chi_times')
>>> chi_docs_dents.head()
         geoid  doc  dentist
0  17031010100    1        1
1  17031010201    0        1
2  17031010202    4        1
3  17031010300    4        1
4  17031010400    0        2
>>> chi_population.head()
         geoid   pop
0  17031010100  4854
1  17031010201  6450
2  17031010202  2818
3  17031010300  6236
4  17031010400  5042
>>> chi_travel_costs.head()
        origin         dest   cost
0  17093890101  17031010100  91.20
1  17093890101  17031010201  92.82
2  17093890101  17031010202  92.95
3  17093890101  17031010300  89.40
4  17093890101  17031010400  84.97

Using the example data, create an Access object.

>>> chicago_primary_care = Access(demand_df = chi_population, demand_index = "geoid",
                                  demand_value = "pop",
                                  supply_df = chi_docs_dents, supply_index = "geoid",
                                  supply_value = ["doc", "dentist"],
                                  cost_df = chi_travel_costs, cost_origin  = "origin",
                                  cost_dest = "destination", cost_name = "cost")

Methods

__init__(demand_df, demand_value, supply_df)

Initialize the class.

append_user_cost(new_cost_df, origin, ...)

Create a user cost, from demand to supply locations.

append_user_cost_neighbors(new_cost_df, ...)

Create a user cost, from supply locations to other supply locations.

create_euclidean_distance([name, threshold, ...])

Calculate the Euclidean distance from demand to supply locations.

create_euclidean_distance_neighbors([name, ...])

Calculate the Euclidean distance among demand locations.

enhanced_two_stage_fca([name, cost, ...])

Calculate the enhanced two-stage floating catchment area access score.

fca_ratio([name, demand_cost, supply_cost, ...])

Calculate the floating catchment area (buffer) ratio access score.

raam([name, cost, supply_values, normalize, ...])

Calculate the rational agent access model.

score(col_dict[, name])

Weighted aggregate of multiple already-calculated, normalized access components.

three_stage_fca([name, cost, supply_values, ...])

Calculate the three-stage floating catchment area access score.

two_stage_fca([name, cost, max_cost, ...])

Calculate the two-stage floating catchment area access score.

weighted_catchment([name, supply_cost, ...])

Calculate the catchment area (buffer) aggregate access score.

Attributes

default_cost

logger_initialized

neighbor_default_cost

norm_access_df