Getting started

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).

Installation

You can install the released version of fca from CRAN with:

install.packages("fca")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("egrueebler/fca")

Example

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
pop <- data.frame(
  orig_id = letters[1:10],
  size = c(100, 200, 50, 100, 500, 50, 100, 100, 50, 500)
)

# Supply df with column for capacity
sup <- data.frame(
  dest_id = as.character(1:3),
  capacity = c(1000, 200, 500)
)

# Distance matrix with travel times from 0 to 30
D <- matrix(
  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  9.883016  5.479408 13.15794 23.312128 16.51924 25.36141 14.22430 28.071914
#> 2 22.476483 17.001595 26.65315  4.526081 16.66584 27.44132 11.22709  8.526582
#> 3  5.942362 21.096330 14.08655 17.038851 22.42528 25.42327 28.07961 21.344232
#>            i         j
#> 1 28.3083878  6.677119
#> 2 10.5915300 15.858798
#> 3  0.6793654 16.098299

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
W <- dist_normalize(
  D,
  d_max = 20,
  imp_function = "gaussian", function_d_max = 0.01
)

# Ensure order of ids
pop <- pop[order(pop$orig_id), ]
sup <- sup[order(sup$dest_id), ]

# Named vectors
(p <- setNames(pop$size, as.character(pop$orig_id)))
#>   a   b   c   d   e   f   g   h   i   j 
#> 100 200  50 100 500  50 100 100  50 500
(s <- setNames(sup$capacity, as.character(sup$dest_id)))
#>    1    2    3 
#> 1000  200  500

Apply FCA method on formatted input, get SPAI for each origin location (p):

(spai <- spai_3sfca(p, s, W))
#>         step3
#> a 2.796129770
#> b 1.608851593
#> c 0.434868954
#> d 1.015616786
#> e 0.077698107
#> f 0.002112822
#> g 0.289558352
#> h 0.571307964
#> i 4.516354779
#> j 1.248905026