library(sf)library(dplyr)library(ggplot2)
library(spatstat.geom)library(spatstat.explore)library(terra)library(viridis)Public bikeshare systems play a central role in contemporary urban transportation by supporting short-distance trips and facilitating first- and last-mile access to high-capacity transit. In Washington, DC, Capital Bikeshare operates independently from the Washington Metropolitan Area Transit Authority (WMATA), yet the two systems are widely understood to function as complementary components of a multimodal transportation network.
While previous research has examined bikeshare demand and station placement using regression and optimization approaches, fewer studies have formally evaluated whether bikeshare station locations exhibit statistically significant spatial structure beyond visual clustering. Understanding whether station locations are randomly distributed, clustered, or spatially associated with transit and population patterns provides insight into the planning logic underlying bikeshare deployment.
This project addresses four research questions:
Do Capital Bikeshare stations exhibit statistically significant spatial clustering relative to complete spatial randomness?
At what spatial scales does clustering occur?
How closely are bikeshare stations located to Metro rail stations?
Does observed clustering align with underlying population distribution across Washington, DC?
Prior research consistently demonstrates that bikeshare systems are shaped by built-environment characteristics, accessibility, and population density. El-Assi et al. (2017) find that bikeshare demand in Toronto is strongly associated with surrounding land use, transit access, and residential density. Wang and Lindsey (2016) similarly show that spatio-temporal interactions play a significant role in shaping bikeshare demand patterns in New York City.
Recent studies have emphasized optimal station placement strategies. Shen et al. (2022) demonstrate that bikeshare stations tend to cluster in dense urban cores with high accessibility, suggesting deliberate planning rather than random placement.
Building on this literature, the present analysis complements demand-based approaches by formally testing the spatial structure of bikeshare stations using spatial point pattern analysis and Monte Carlo simulation.
All spatial datasets were obtained from authoritative public sources:
Capital Bikeshare station locations (DC Open Data Portal)
Washington, DC boundary (DC Open Data Portal)
Metro rail station locations (DC Open Data Portal)
2020 Census tract geometries and population counts (U.S. Census Bureau, Decennial Census)
Population totals are drawn from Census Table P001 (Total Population).
All datasets were projected to NAD83 / UTM Zone 18N (EPSG: 26918). This projection ensures that distances and areas are measured in meters, which is required for spatial point pattern analysis and distance-based inference.
Bikeshare stations were filtered to include only those located within the Washington, DC boundary. The city boundary polygon was converted into a planar observation window defining the study region for point pattern analysis.
First-order spatial structure was examined using kernel-smoothed intensity estimation, which provides a continuous surface of expected station density. Second-order spatial structure was assessed using Ripley’s K-function and the pair-correlation function (PCF). Monte Carlo envelopes were generated under a complete spatial randomness (CSR) null model using 99 simulations.
To contextualize observed clustering, census tract–level population density was mapped using a choropleth. Bikeshare stations were overlaid to assess whether clustering corresponds to residential population concentration.
library(sf)library(dplyr)library(ggplot2)
library(spatstat.geom)library(spatstat.explore)library(terra)library(viridis)target_crs <- 26918
cabi <- st_read("data/Capital_Bike_Share_Locations/Capital_Bike_Share_Locations.shp", quiet=TRUE) |>
st_transform(target_crs)
dc_boundary <- st_read("data/Washington_DC_Boundary/Washington_DC_Boundary.shp", quiet=TRUE) |>
st_transform(target_crs)
metro <- st_read("data/Metro_Stations_in_DC/Metro_Stations_in_DC.shp", quiet=TRUE) |>
st_transform(target_crs)
tracts <- st_read("data/Census_Tracts_in_2020/Census_Tracts_in_2020.shp", quiet=TRUE) |>
st_transform(target_crs)
cabi <- cabi[st_within(cabi, dc_boundary, sparse = FALSE), ]
dc_owin <- as.owin(st_union(dc_boundary))
coords <- st_coordinates(cabi)
cabi_ppp <- ppp(coords[,1], coords[,2], window = dc_owin)ggplot() +
geom_sf(data = dc_boundary, fill = "grey95", color = "black") +
geom_sf(data = cabi, color = "red", alpha = 0.8, size = 1) +
geom_sf(data = metro, color = "blue", size = 2.5) +
labs(
title = "Capital Bikeshare and Metro Stations in Washington, DC",
subtitle = "Base map for spatial point pattern analysis"
) +
theme_minimal(base_size = 14)CaBi stations are concentrated in the urban core, with many stations visually co-located near the Metro network. This map motivates formal point-pattern testing to determine whether this apparent clustering is statistically distinguishable from complete spatial randomness.
lambda <- density(cabi_ppp, sigma = bw.ppl(cabi_ppp), edge = TRUE)
lambda_df <- as.data.frame(rast(lambda), xy = TRUE)
lambda_df <- as.data.frame(rast(lambda), xy = TRUE)
colnames(lambda_df) <- c("x", "y", "lambda")
ggplot() +
geom_raster(data = lambda_df, aes(x = x, y = y, fill = lambda)) +
geom_sf(data = dc_boundary, fill = NA, color = "grey40") +
geom_sf(data = metro, color = "white", size = 1.2) +
scale_fill_viridis(option = "magma", name = "Intensity") +
labs(
title = "Kernel-Smoothed Intensity of Capital Bikeshare Stations"
) +
theme_minimal(base_size = 14)The kernel intensity surface indicates the highest expected station density in central DC, with lower density toward the periphery. This pattern suggests a structured deployment consistent with higher activity and accessibility in the urban core.
set.seed(123)
K_env <- envelope(
cabi_ppp,
fun = Kest,
nsim = 99,
global = TRUE,
simulate = expression(runifpoint(cabi_ppp$n, win = dc_owin))
)Generating 198 simulations by evaluating expression (99 to estimate the mean
and 99 to calculate envelopes) ...
1, 2,
[37:55 remaining, estimate finish 2025-12-20 20:31:37]
3, 4
[35:52 remaining, estimate finish 2025-12-20 20:29:56]
.6
[36:13 remaining, estimate finish 2025-12-20 20:30:40]
.8
[36:12 remaining, estimate finish 2025-12-20 20:31:03]
.10
[35:41 remaining, estimate finish 2025-12-20 20:30:54]
.12
[35:10 remaining, estimate finish 2025-12-20 20:30:46]
.14
[35:00 remaining, estimate finish 2025-12-20 20:30:59]
.16
[34:30 remaining, estimate finish 2025-12-20 20:30:51]
.18
[34:11 remaining, estimate finish 2025-12-20 20:30:56]
.20
[34:05 remaining, estimate finish 2025-12-20 20:31:14]
.22
[33:35 remaining, estimate finish 2025-12-20 20:31:06]
.24
[33:08 remaining, estimate finish 2025-12-20 20:31:01]
.26
[32:36 remaining, estimate finish 2025-12-20 20:30:51]
.28
[32:09 remaining, estimate finish 2025-12-20 20:30:46]
.30
[31:39 remaining, estimate finish 2025-12-20 20:30:38]
.32
[31:18 remaining, estimate finish 2025-12-20 20:30:40]
.34
[30:55 remaining, estimate finish 2025-12-20 20:30:39]
.36
[30:31 remaining, estimate finish 2025-12-20 20:30:37]
.38
[30:04 remaining, estimate finish 2025-12-20 20:30:32]
.40
[29:45 remaining, estimate finish 2025-12-20 20:30:36]
.42
[29:21 remaining, estimate finish 2025-12-20 20:30:34]
.44
[28:56 remaining, estimate finish 2025-12-20 20:30:31]
.46
[28:34 remaining, estimate finish 2025-12-20 20:30:31]
.48
[28:11 remaining, estimate finish 2025-12-20 20:30:32]
.50
[27:47 remaining, estimate finish 2025-12-20 20:30:30]
.52
[27:27 remaining, estimate finish 2025-12-20 20:30:33]
.54
[27:04 remaining, estimate finish 2025-12-20 20:30:32]
.56
[26:39 remaining, estimate finish 2025-12-20 20:30:29]
.58
[26:19 remaining, estimate finish 2025-12-20 20:30:32]
.60
[25:56 remaining, estimate finish 2025-12-20 20:30:32]
.62
[25:32 remaining, estimate finish 2025-12-20 20:30:30]
.64
[25:07 remaining, estimate finish 2025-12-20 20:30:26]
.66
[24:44 remaining, estimate finish 2025-12-20 20:30:26]
.68
[24:23 remaining, estimate finish 2025-12-20 20:30:27]
.70
[24:01 remaining, estimate finish 2025-12-20 20:30:28]
.72
[23:37 remaining, estimate finish 2025-12-20 20:30:26]
.74
[23:15 remaining, estimate finish 2025-12-20 20:30:26]
.76
[22:53 remaining, estimate finish 2025-12-20 20:30:28]
.78
[22:32 remaining, estimate finish 2025-12-20 20:30:30]
.80
[22:10 remaining, estimate finish 2025-12-20 20:30:30]
.82
[21:46 remaining, estimate finish 2025-12-20 20:30:29]
.84
[21:23 remaining, estimate finish 2025-12-20 20:30:28]
.86
[21:01 remaining, estimate finish 2025-12-20 20:30:29]
.88
[20:38 remaining, estimate finish 2025-12-20 20:30:28]
.90
[20:16 remaining, estimate finish 2025-12-20 20:30:29]
.92
[19:55 remaining, estimate finish 2025-12-20 20:30:31]
.94
[19:32 remaining, estimate finish 2025-12-20 20:30:31]
.96
[19:09 remaining, estimate finish 2025-12-20 20:30:29]
.98
[18:45 remaining, estimate finish 2025-12-20 20:30:26]
.100
[18:23 remaining, estimate finish 2025-12-20 20:30:28]
.102
[17:59 remaining, estimate finish 2025-12-20 20:30:25]
.104
[17:38 remaining, estimate finish 2025-12-20 20:30:27]
.106
[17:15 remaining, estimate finish 2025-12-20 20:30:28]
.108
[16:54 remaining, estimate finish 2025-12-20 20:30:29]
.110
[16:30 remaining, estimate finish 2025-12-20 20:30:28]
.112
[16:08 remaining, estimate finish 2025-12-20 20:30:28]
.114
[15:47 remaining, estimate finish 2025-12-20 20:30:31]
.116
[15:24 remaining, estimate finish 2025-12-20 20:30:31]
.118
[15:02 remaining, estimate finish 2025-12-20 20:30:32]
.120
[14:40 remaining, estimate finish 2025-12-20 20:30:34]
.122
[14:17 remaining, estimate finish 2025-12-20 20:30:32]
.124
[13:54 remaining, estimate finish 2025-12-20 20:30:32]
.126
[13:32 remaining, estimate finish 2025-12-20 20:30:32]
.128
[13:09 remaining, estimate finish 2025-12-20 20:30:31]
.130
[12:46 remaining, estimate finish 2025-12-20 20:30:29]
.132
[12:24 remaining, estimate finish 2025-12-20 20:30:30]
.134
[12:01 remaining, estimate finish 2025-12-20 20:30:29]
.136
[11:38 remaining, estimate finish 2025-12-20 20:30:30]
.138
[11:15 remaining, estimate finish 2025-12-20 20:30:28]
.140
[10:52 remaining, estimate finish 2025-12-20 20:30:26]
.142
[10:29 remaining, estimate finish 2025-12-20 20:30:25]
.144
[10:07 remaining, estimate finish 2025-12-20 20:30:24]
.146 [9:44 remaining] .148 [9:22 remaining] .150 [8:59 remaining] .152 [8:36 remaining] .154 [8:14 remaining] .156 [7:52 remaining] .158 [7:30 remaining] .160 [7:07 remaining] .162 [6:45 remaining] .164 [6:22 remaining] .166 [6:00 remaining] .168 [5:37 remaining] .170 [5:15 remaining] .172 [4:52 remaining] .174 [4:30 remaining] .176 [4:07 remaining] .178 [3:45 remaining] .180 [3:22 remaining] .182 [3:00 remaining] .184
[2:37 remaining] .186 [2:15 remaining] .188 [1:52 remaining] .190 [1:30 remaining] .192 [1:08 remaining] .194 [45 sec remaining] .196 [23 sec remaining] .
198.
Done.
plot(K_env,
main = "Ripley's K-function Envelope (CSR Null Model)",
xlab = "Distance r (meters)",
ylab = "K(r)")The observed Ripley’s K-function lies well above the upper CSR envelope across the entire spatial domain, from neighborhood scales (~500 m) through citywide distances (~4.5 km). At 2.5 km, the observed cumulative neighbor count is roughly twice what would be expected under complete spatial randomness. This consistent divergence provides strong evidence against the CSR null hypothesis and indicates persistent global clustering in Capital Bikeshare station placement.
pcf_env <- envelope(
cabi_ppp,
fun = pcf,
nsim = 99,
global = TRUE,
simulate = expression(runifpoint(cabi_ppp$n, win = dc_owin))
)Generating 198 simulations by evaluating expression (99 to estimate the mean
and 99 to calculate envelopes) ...
1, 2,
[37:06 remaining, estimate finish 2025-12-20 21:08:12]
3, 4
[38:49 remaining, estimate finish 2025-12-20 21:10:20]
.6
[38:00 remaining, estimate finish 2025-12-20 21:09:54]
.8
[37:51 remaining, estimate finish 2025-12-20 21:10:10]
.10
[37:22 remaining, estimate finish 2025-12-20 21:10:04]
.12
[36:30 remaining, estimate finish 2025-12-20 21:09:35]
.14
[35:59 remaining, estimate finish 2025-12-20 21:09:26]
.16
[35:31 remaining, estimate finish 2025-12-20 21:09:22]
.18
[35:13 remaining, estimate finish 2025-12-20 21:09:27]
.20
[34:30 remaining, estimate finish 2025-12-20 21:09:06]
.22
[34:07 remaining, estimate finish 2025-12-20 21:09:06]
.24
[33:38 remaining, estimate finish 2025-12-20 21:08:59]
.26
[33:03 remaining, estimate finish 2025-12-20 21:08:46]
.28
[32:42 remaining, estimate finish 2025-12-20 21:08:48]
.30
[32:18 remaining, estimate finish 2025-12-20 21:08:47]
.32
[31:52 remaining, estimate finish 2025-12-20 21:08:44]
.34
[31:40 remaining, estimate finish 2025-12-20 21:08:57]
.36
[31:16 remaining, estimate finish 2025-12-20 21:08:56]
.38
[30:49 remaining, estimate finish 2025-12-20 21:08:51]
.40
[30:22 remaining, estimate finish 2025-12-20 21:08:47]
.42
[30:01 remaining, estimate finish 2025-12-20 21:08:49]
.44
[29:35 remaining, estimate finish 2025-12-20 21:08:46]
.46
[29:14 remaining, estimate finish 2025-12-20 21:08:49]
.48
[28:56 remaining, estimate finish 2025-12-20 21:08:54]
.50
[28:35 remaining, estimate finish 2025-12-20 21:08:57]
.52
[28:13 remaining, estimate finish 2025-12-20 21:08:59]
.54
[27:48 remaining, estimate finish 2025-12-20 21:08:57]
.56
[27:22 remaining, estimate finish 2025-12-20 21:08:53]
.58
[27:01 remaining, estimate finish 2025-12-20 21:08:55]
.60
[26:39 remaining, estimate finish 2025-12-20 21:08:57]
.62
[26:14 remaining, estimate finish 2025-12-20 21:08:54]
.64
[25:50 remaining, estimate finish 2025-12-20 21:08:53]
.66
[25:26 remaining, estimate finish 2025-12-20 21:08:52]
.68
[25:02 remaining, estimate finish 2025-12-20 21:08:51]
.70
[24:39 remaining, estimate finish 2025-12-20 21:08:52]
.72
[24:17 remaining, estimate finish 2025-12-20 21:08:53]
.74
[23:54 remaining, estimate finish 2025-12-20 21:08:53]
.76
[23:31 remaining, estimate finish 2025-12-20 21:08:53]
.78
[23:08 remaining, estimate finish 2025-12-20 21:08:53]
.80
[22:45 remaining, estimate finish 2025-12-20 21:08:53]
.82
[22:22 remaining, estimate finish 2025-12-20 21:08:54]
.84
[21:59 remaining, estimate finish 2025-12-20 21:08:54]
.86
[21:36 remaining, estimate finish 2025-12-20 21:08:55]
.88
[21:13 remaining, estimate finish 2025-12-20 21:08:54]
.90
[20:49 remaining, estimate finish 2025-12-20 21:08:52]
.92
[20:24 remaining, estimate finish 2025-12-20 21:08:50]
.94
[20:02 remaining, estimate finish 2025-12-20 21:08:51]
.96
[19:38 remaining, estimate finish 2025-12-20 21:08:51]
.98
[19:15 remaining, estimate finish 2025-12-20 21:08:51]
.100
[18:52 remaining, estimate finish 2025-12-20 21:08:50]
.102
[18:29 remaining, estimate finish 2025-12-20 21:08:51]
.104
[18:06 remaining, estimate finish 2025-12-20 21:08:52]
.106
[17:43 remaining, estimate finish 2025-12-20 21:08:51]
.108
[17:20 remaining, estimate finish 2025-12-20 21:08:51]
.110
[16:56 remaining, estimate finish 2025-12-20 21:08:49]
.112
[16:33 remaining, estimate finish 2025-12-20 21:08:50]
.114
[16:11 remaining, estimate finish 2025-12-20 21:08:51]
.116
[15:48 remaining, estimate finish 2025-12-20 21:08:51]
.118
[15:24 remaining, estimate finish 2025-12-20 21:08:50]
.120
[15:01 remaining, estimate finish 2025-12-20 21:08:50]
.122
[14:37 remaining, estimate finish 2025-12-20 21:08:48]
.124
[14:13 remaining, estimate finish 2025-12-20 21:08:46]
.126
[13:50 remaining, estimate finish 2025-12-20 21:08:46]
.128
[13:27 remaining, estimate finish 2025-12-20 21:08:46]
.130
[13:03 remaining, estimate finish 2025-12-20 21:08:44]
.132
[12:41 remaining, estimate finish 2025-12-20 21:08:46]
.134
[12:17 remaining, estimate finish 2025-12-20 21:08:44]
.136
[11:55 remaining, estimate finish 2025-12-20 21:08:46]
.138
[11:32 remaining, estimate finish 2025-12-20 21:08:47]
.140
[11:08 remaining, estimate finish 2025-12-20 21:08:45]
.142
[10:45 remaining, estimate finish 2025-12-20 21:08:45]
.144
[10:22 remaining, estimate finish 2025-12-20 21:08:44]
.146 [9:59 remaining] .148 [9:36 remaining] .150 [9:13 remaining] .152 [8:51 remaining] .154 [8:28 remaining] .156 [8:05 remaining] .158 [7:42 remaining] .160 [7:19 remaining] .162 [6:55 remaining] .164 [6:32 remaining] .166 [6:09 remaining] .168 [5:46 remaining] .170 [5:23 remaining] .172 [5:00 remaining] .174 [4:37 remaining] .176 [4:14 remaining] .178 [3:51 remaining] .180 [3:27 remaining] .182 [3:04 remaining] .184
[2:41 remaining] .186 [2:18 remaining] .188 [1:55 remaining] .190 [1:32 remaining] .192 [1:09 remaining] .194 [46 sec remaining] .196 [23 sec remaining] .
198.
Done.
plot(pcf_env,
main = "Pair-Correlation Function Envelope (CSR Null Model)",
xlab = "Distance r (meters)",
ylab = "g(r)")The pair-correlation function reveals strong local-scale clustering, with peak interaction occurring between approximately 300 and 600 meters, where observed station density is more than 2.5 times the CSR expectation. This distance band corresponds closely to walkable urban block scales. At very short distances (<100 m), g(r) < 1 indicates spacing constraints that prevent stations from being colocated. Together, these results show that bikeshare stations are deliberately clustered at neighborhood-relevant distances rather than randomly dispersed.
tracts <- tracts %>%
mutate(
area_km2 = as.numeric(st_area(geometry) / 1e6),
pop_density = P0010001 / area_km2
)
ggplot() +
geom_sf(data = tracts, aes(fill = pop_density), color = NA) +
geom_sf(data = cabi, color = "black", size = 0.5, alpha = 0.6) +
scale_fill_viridis(
option = "plasma",
name = "Population density\n(people per km²)"
) +
labs(
title = "Population Density and Capital Bikeshare Stations",
subtitle = "2020 Census tract population density"
) +
theme_minimal(base_size = 14)Census tract population density varies by nearly an order of magnitude across Washington, DC, ranging from under 5,000 people per km² in peripheral areas to over 30,000 people per km² in the urban core. Capital Bikeshare stations are overwhelmingly concentrated within high-density tracts, with particularly dense clusters aligning with the most populous neighborhoods. This spatial correspondence indicates that the strong clustering detected by the K-function and PCF reflects underlying population distribution rather than random spatial processes.
Across all diagnostics, Capital Bikeshare stations in DC display strong spatial structure that is inconsistent with complete spatial randomness. The first-order intensity surface highlights a dense central core, while the second-order CSR envelopes show significant clustering across a broad set of spatial scales. The Metro distance histogram further supports an interpretation of multimodal integration: stations are frequently placed within walking distance of rail entrances. Finally, the population-density choropleth indicates that the station network is aligned with tract-level population concentration, reinforcing the idea that deployment patterns reflect demand and accessibility considerations.
A key implication is that bikeshare station locations are shaped by deliberate planning logic and multimodal connectivity. In the DC context, station clustering appears to reflect both (i) dense population and activity centers and (ii) the goal of complementing the Metro network for first/last-mile trips.
This project demonstrates how spatial point pattern analysis can formally evaluate whether transportation infrastructure is randomly distributed or spatially structured. Using kernel intensity estimation, CSR simulation envelopes for Ripley’s K and the pair-correlation function, nearest-station distance analysis, and tract-level population density context, the results indicate that Capital Bikeshare stations are highly clustered and strongly integrated with the Metro system. These findings are consistent with a planned network designed to support short trips and strengthen multimodal accessibility in Washington, DC.