Registry / data / spatial-access

spatial-access

JSON →
library1.0.2pypypiunverified

spatial-access is a Python package designed for measuring spatial accessibility to services. It provides tools to construct road networks, represent facilities and demand points, and compute various accessibility metrics like the Two-Step Floating Catchment Area (2SFCA) method. The current version is 1.0.2, and releases are made as needed to address issues and introduce features.

pip install spatial-access
INSTALL
IMPORT
SIG · SPATIAL-ACCESS
S
spatial-access
datapythonv1.0.2
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

spatial_access
import spatial_access as sa
import spatial-access
Python import statements use underscores, not hyphens, even if the PyPI package name uses hyphens.
Network
network = sa.Network(nodes, edges, 'weight_col')
The Network class is typically accessed via the top-level spatial_access module alias.
Access
access_model = sa.Access(network, facilities, demand, 'facility_col', 'demand_col')
The Access class is typically accessed via the top-level spatial_access module alias.

This quickstart demonstrates how to create a simple road network, define facilities and demand points using GeoDataFrames, and then compute spatial accessibility using the Two-Step Floating Catchment Area (2SFCA) method. It uses dummy data to ensure the example is runnable out-of-the-box.

from shapely.geometry import Point, LineString import geopandas as gpd import pandas as pd import spatial_access as sa # 1. Create dummy network data (nodes and edges) # Nodes represent intersections or endpoints nodes_df = pd.DataFrame({ 'id': [0, 1, 2, 3], 'geometry': [Point(0, 0), Point(1, 0), Point(0, 1), Point(1, 1)] }) nodes = gpd.GeoDataFrame(nodes_df, crs="EPSG:4326") # Edges represent road segments connecting nodes edges_df = pd.DataFrame({ 'id': [0, 1, 2, 3], 'from': [0, 0, 1, 2], 'to': [1, 2, 3, 3], 'length': [1.0, 1.0, 1.0, 1.0], # A 'weight' or 'cost' column 'geometry': [ LineString([(0, 0), (1, 0)]), LineString([(0, 0), (0, 1)]), LineString([(1, 0), (1, 1)]), LineString([(0, 1), (1, 1)]) ] }) edges = gpd.GeoDataFrame(edges_df, crs="EPSG:4326") # 2. Create dummy facility and demand data # Facilities (e.g., hospitals, stores) with capacity facilities_df = pd.DataFrame({ 'id': [0, 1], 'capacity': [10, 15], 'geometry': [Point(0.1, 0.1), Point(0.9, 0.9)] }) facilities = gpd.GeoDataFrame(facilities_df, crs="EPSG:4326") # Demand points (e.g., population centroids) with demand demand_df = pd.DataFrame({ 'id': [0, 1], 'demand': [5, 8], 'geometry': [Point(0.2, 0.2), Point(0.8, 0.8)] }) demand = gpd.GeoDataFrame(demand_df, crs="EPSG:4326") # 3. Initialize Network and Access objects # The 'length' column is used as the weight for shortest path calculations network = sa.Network(nodes, edges, "length") # Create the Access model, linking network, facilities, and demand access_model = sa.Access(network, facilities, demand, "capacity", "demand") # 4. Compute 2SFCA accessibility # Using a distance threshold of 10 units (arbitrary for dummy data) # and a Gaussian weight function. The result is (Si, Dj) where Si is # accessibility for demand points and Dj for facilities. print("Calculating 2SFCA accessibility...") accessibility_scores = access_model.two_sfca(10, weight_function="gaussian") # Print accessibility scores for demand points print("\nAccessibility scores for demand points (Si):") print(accessibility_scores[0].head())
Debug
Known issues
breakingPrior to version 1.0.2, the internal C++ Dijkstra implementation could crash when the input road network contained multiple disconnected components, leading to unexpected program termination.
fix
Upgrade to version 1.0.2 or newer. Alternatively, ensure your input network is a single connected component or filter to the largest connected component before processing.
affects: <1.0.2
gotchaDropping non-existent columns from a road network GeoDataFrame would previously raise an error, interrupting the workflow.
fix
Upgrade to version 1.0.2 or newer, which gracefully handles attempts to drop non-existent columns. For older versions, ensure all specified columns for removal actually exist in the DataFrame.
affects: <1.0.2
gotchaCoordinate Reference System (CRS) mismatches between input GeoDataFrames (nodes, edges, facilities, demand) can lead to incorrect distance calculations or errors during spatial operations. All input GeoDataFrames must share the same CRS.
fix
Always ensure that `nodes`, `edges`, `facilities`, and `demand` GeoDataFrames have a consistent CRS. Reproject them if necessary using `.to_crs()` before creating `Network` or `Access` objects. For example: `gdf.to_crs('EPSG:26918')` for projected coordinates suitable for distance calculations.
affects: All versions
gotchaThe `spatial_access.Network` object expects specific column names for weights (e.g., 'length', 'travel_time') and the `Access` object expects 'capacity' and 'demand' columns. Using incorrect column names will result in `KeyError`.
fix
Verify that the column names passed to `sa.Network` and `sa.Access` constructors (e.g., `weight_col`, `facility_col_name`, `demand_col_name`) exactly match the column names in your input GeoDataFrames.
affects: All versions
Upgrade
Version history
1.0.2latest on PyPI · released Jan 11, 2022
Audit
Dependencies
geopandasrequiredFundamental for handling geographic data structures (GeoDataFrames) for networks, facilities, and demand points.
pandasrequiredUsed for data manipulation and integration with GeoDataFrames.
networkxrequiredPowers the underlying graph representation and algorithms for network analysis.
Agent activity
3 hits · last 30 days
node
2
OpenAI (training)
1
Resources
spatial-access — pip install spatial-access · libregistry