Floating Catchment Area (FCA) methods to Calculate Spatial Accessibility.
Perform various floating catchment area methods to calculate a spatial accessibility index (SPAI) for demand point data. The distance matrix used for weighting is normalized in a preprocessing step using common functions (gaussian, gravity, exponential or logistic).
You can install the released version of fca from CRAN with:
install.packages("fca")
And the development version from GitHub with:
# install.packages("devtools")
::install_github("egrueebler/fca") devtools
This is a basic example which shows you how to calculate a SPAI for demand point data using FCA methods.
Create an example population, supply and distances:
# Population df with column for size
<- data.frame(
pop orig_id = letters[1:10],
size = c(100, 200, 50, 100, 500, 50, 100, 100, 50, 500)
)
# Supply df with column for capacity
<- data.frame(
sup dest_id = as.character(1:3),
capacity = c(1000, 200, 500)
)
# Distance matrix with travel times from 0 to 30
<- matrix(
D runif(30, min = 0, max = 30),
ncol = 10, nrow = 3, byrow = TRUE,
dimnames = list(c(1:3), c(letters[1:10]))
)
D#> a b c d e f g h
#> 1 1.165296 23.940221 4.420221 24.338810 29.40716 10.99555 15.99315 22.0770353
#> 2 22.250196 5.106196 18.901658 23.243694 28.74460 29.89078 21.85673 13.1939604
#> 3 20.711940 7.165924 22.205717 4.813175 27.29280 25.16371 13.64475 0.3557868
#> i j
#> 1 8.846327 5.491492
#> 2 27.544878 9.992862
#> 3 17.380077 7.127191
Normalize distance matrix with gaussian function, apply a threshold of 20 minutes (to compute beta for the function) and formatting input data as named vectors for the FCA method (match IDs of distance weight matrix with demand and supply data).
library(fca)
# Normalize distances
<- dist_normalize(
W
D,d_max = 20,
imp_function = "gaussian", function_d_max = 0.01
)
# Ensure order of ids
<- pop[order(pop$orig_id), ]
pop <- sup[order(sup$dest_id), ]
sup
# Named vectors
<- setNames(pop$size, as.character(pop$orig_id)))
(p #> a b c d e f g h i j
#> 100 200 50 100 500 50 100 100 50 500
<- setNames(sup$capacity, as.character(sup$dest_id)))
(s #> 1 2 3
#> 1000 200 500
Apply FCA method on formatted input, get SPAI for each origin location (p
):
<- spai_3sfca(p, s, W))
(spai #> step3
#> a 2.9771456866
#> b 1.0897984651
#> c 2.3821799172
#> d 1.2009856195
#> e 0.0002327127
#> f 0.7575795086
#> g 0.1732212020
#> h 1.4077847838
#> i 1.1566673716
#> j 1.3823777631