Catchment¶
sdc_catchment ¶
sdc-catchment: floating catchment area spatial accessibility.
catchment_connections ¶
catchment_connections(cost, weight: WeightSpec = None, consumer_ids=None, provider_ids=None, **weight_kwargs) -> pd.DataFrame
Extract non-zero consumer-provider connections with weights and costs.
Source code in packages/sdc-catchment/src/sdc_catchment/catchment.py
catchment_network ¶
Extract connected subgraph via breadth-first search.
Source code in packages/sdc-catchment/src/sdc_catchment/catchment.py
catchment_ratio ¶
catchment_ratio(consumers: DataFrame, providers: DataFrame, cost, weight: WeightSpec = None, scale: float = 2.0, max_cost: float | None = None, normalize_weight: bool = False, adjust_consumers: Callable | None = None, adjust_providers: Callable | None = None, consumers_commutes=None, consumers_id: str = 'geoid', consumers_value: str = 'value', providers_id: str = 'geoid', providers_value: str = 'value', adjust_zeros: float | bool = 1e-06, return_type: str | int | float = 'original') -> pd.Series
Calculate provider-to-consumer ratios within floating catchment areas.
Source code in packages/sdc-catchment/src/sdc_catchment/catchment.py
catchment_weight ¶
catchment_weight(cost, weight: WeightSpec = None, max_cost: float | None = None, scale: float = 2.0, normalize_weight: bool = False, adjust_zeros: float | bool = 1e-06) -> sparse.csc_matrix
Construct a weight matrix from a cost matrix using kernel decay functions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cost
|
sparse matrix, ndarray, or DataFrame
|
Cost/distance matrix. Rows = consumers, columns = providers. |
required |
weight
|
WeightSpec
|
None = use cost as weight. float = binary threshold (exclusive: cost < threshold). list of (distance, weight) tuples = stepped. str = kernel name. callable = custom function (cost_matrix) -> weight_matrix. |
None
|
max_cost
|
float or None
|
Zero out weights where cost exceeds this value. |
None
|
scale
|
float
|
Scale parameter for kernel functions. |
2.0
|
normalize_weight
|
bool
|
Apply 3SFCA selection probability: w * (w / rowsum). NOT simple row normalization. |
False
|
adjust_zeros
|
float or False
|
Replace zeros in cost with this value. Skipped when weight is None. |
1e-06
|
Returns:
| Type | Description |
|---|---|
csc_matrix
|
|
Source code in packages/sdc-catchment/src/sdc_catchment/catchment.py
euclidean_cost ¶
Compute Euclidean distance matrix between consumer and provider coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
consumers_xy
|
ndarray of shape (n, 2)
|
Consumer coordinates (x, y). |
required |
providers_xy
|
ndarray of shape (m, 2)
|
Provider coordinates (x, y). |
required |
Returns:
| Type | Description |
|---|---|
ndarray of shape (n, m)
|
Pairwise Euclidean distances. |