Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dhersz committed Mar 6, 2024
1 parent 84ee367 commit bfbb423
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 139 deletions.
110 changes: 53 additions & 57 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,22 @@ knitr::opts_chunk$set(
[![CRAN
status](https://www.r-pkg.org/badges/version/accessibility)](https://CRAN.R-project.org/package=accessibility)
[![rcmdcheck](https://github.com/ipeaGIT/accessibility/workflows/rcmdcheck/badge.svg)](https://github.com/ipeaGIT/accessibility/actions)
[![CRAN/METACRAN Total downloads](http://cranlogs.r-pkg.org/badges/grand-total/accessibility?color=yellow)](https://CRAN.R-project.org/package=accessibility)
[![Codecov test coverage](https://codecov.io/gh/ipeaGIT/accessibility/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ipeaGIT/accessibility?branch=main)
[![Lifecycle: stable](https://lifecycle.r-lib.org/articles/figures/lifecycle-stable.svg)](https://lifecycle.r-lib.org/articles/stages.html)

**accessibility** offers a set of fast and convenient functions to calculate
multiple transport accessibility measures. Given a pre-computed travel cost
matrix and a land use dataset (containing the location of jobs, healthcare and
population, for example), the package allows one to calculate active and
passive accessibility levels using multiple accessibility measures, such as:
cumulative opportunities (using either travel cost cutoffs or intervals),
minimum travel cost to closest N number of activities, gravity-based (with
different decay functions) and different floating catchment area methods.
[![CRAN/METACRAN Total
downloads](http://cranlogs.r-pkg.org/badges/grand-total/accessibility?color=yellow)](https://CRAN.R-project.org/package=accessibility)
[![Codecov test
coverage](https://codecov.io/gh/ipeaGIT/accessibility/branch/main/graph/badge.svg)](https://app.codecov.io/gh/ipeaGIT/accessibility?branch=main)
[![Lifecycle:
stable](https://lifecycle.r-lib.org/articles/figures/lifecycle-stable.svg)](https://lifecycle.r-lib.org/articles/stages.html)

**accessibility** offers a set of fast and convenient functions to help
conducting accessibility analyses. Given a pre-computed travel cost matrix and a
land use dataset (containing the location of jobs, healthcare and population,
for example), the package allows one to calculate accessibility levels and
accessibility poverty and inequality. The package covers the majority of the
most commonly used accessibility measures (such as cumulative opportunities,
gravity-based and floating catchment areas methods), as well as the most
frequently used inequality and poverty metrics (such as the Palma ratio, the
concentration and Theil indices and the FGT family of measures).

## Installation

Expand All @@ -46,25 +50,29 @@ Development version:
remotes::install_github("ipeaGIT/accessibility")
```

## Basic usage
## Usage

This section aims to present a very brief overview of some of the packages'
features. Fore more details please read the vignettes:

- [Introduction to **accessibility**: calculating accessibility
measures](https://ipeagit.github.io/accessibility/articles/accessibility.html)
- [Decay
functions](https://ipeagit.github.io/accessibility/articles/decay_functions.html)
- [Calculating accessibility inequality and
poverty](https://ipeagit.github.io/accessibility/articles/inequality_and_poverty.html)

To calculate accessibility levels, one simply needs a pre-calculated travel
matrix and some land use data. Below we showcase some of the available
functions:

```{r}
library(accessibility)
# required data: a travel matrix and some land use data
data_dir <- system.file("extdata", package = "accessibility")
travel_matrix <- readRDS(file.path(data_dir, "travel_matrix.rds"))
land_use_data <- readRDS(file.path(data_dir, "land_use_data.rds"))
cost_closest <- cost_to_closest(
travel_matrix,
land_use_data,
opportunity = "schools",
travel_cost = "travel_time",
n = 1
)
head(cost_closest)
cum_cutoff <- cumulative_cutoff(
travel_matrix,
land_use_data,
Expand All @@ -74,15 +82,6 @@ cum_cutoff <- cumulative_cutoff(
)
head(cum_cutoff)
cum_interval <- cumulative_interval(
travel_matrix,
land_use_data,
opportunity = "jobs",
travel_cost = "travel_time",
interval = c(20, 30)
)
head(cum_interval)
grav <- gravity(
travel_matrix,
land_use_data,
Expand All @@ -102,43 +101,40 @@ fca <- floating_catchment_area(
decay_function = decay_binary(cutoff = 50)
)
head(fca)
```

sptl_avlblt <- spatial_availability(
travel_matrix,
land_use_data,
Calculating inequality and poverty levels is equally easy. Below we use the
previously calculated cumulative accessibility dataset to show some of the
available inequality and poverty functions:

```{r}
palma <- palma_ratio(
cum_cutoff,
sociodemographic_data = land_use_data,
opportunity = "jobs",
travel_cost = "travel_time",
demand = "population",
decay_function = decay_exponential(decay_value = 0.1)
population = "population",
income = "income_per_capita"
)
head(sptl_avlblt)
palma
bc <- balancing_cost(
travel_matrix,
land_use_data,
poverty <- fgt_poverty(
cum_cutoff,
sociodemographic_data = land_use_data,
opportunity = "jobs",
travel_cost = "travel_time",
demand = "population"
population = "population",
poverty_line = 95368
)
head(bc)
poverty
```

Please read the vignettes for more details on the usage:

- Introduction to **accessibility**: calculating accessibility measures. Run
[`vignette("accessibility")`](https://ipeagit.github.io/accessibility/articles/accessibility.html).
- Decay functions. Run [`vignette("decay_functions", package =
"accessibility")`](https://ipeagit.github.io/accessibility/articles/decay_functions.html).
- Calculating accessibility inequality and poverty. Run
[`vignette("inequality_and_poverty", package =
"accessibility")`](https://ipeagit.github.io/accessibility/articles/inequality_and_poverty.html).

## Related work:

- [r5r](https://github.com/ipeaGIT/r5r): Rapid Realistic Routing with R5 in R
- [tracc](https://github.com/jamaps/tracc): Transport accessibility measures in Python
- [tracc](https://github.com/jamaps/tracc): Transport accessibility measures in
Python
- [access](https://access.readthedocs.io/en/latest/): Spatial Access for PySAL
- [aceso](https://github.com/tetraptych/aceso): a lightweight Python package for measuring spatial accessibility
- [aceso](https://github.com/tetraptych/aceso): a lightweight Python package for
measuring spatial accessibility

## Acknowledgement <a href="https://www.ipea.gov.br"><img src="man/figures/ipea_logo.png" alt="IPEA" align="right" width="300"/></a>

Expand Down
130 changes: 48 additions & 82 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ coverage](https://codecov.io/gh/ipeaGIT/accessibility/branch/main/graph/badge.sv
[![Lifecycle:
stable](https://lifecycle.r-lib.org/articles/figures/lifecycle-stable.svg)](https://lifecycle.r-lib.org/articles/stages.html)

**accessibility** offers a set of fast and convenient functions to
calculate multiple transport accessibility measures. Given a
pre-computed travel cost matrix and a land use dataset (containing the
location of jobs, healthcare and population, for example), the package
allows one to calculate active and passive accessibility levels using
multiple accessibility measures, such as: cumulative opportunities
(using either travel cost cutoffs or intervals), minimum travel cost to
closest N number of activities, gravity-based (with different decay
functions) and different floating catchment area methods.
**accessibility** offers a set of fast and convenient functions to help
conducting accessibility analyses. Given a pre-computed travel cost
matrix and a land use dataset (containing the location of jobs,
healthcare and population, for example), the package allows one to
calculate accessibility levels and accessibility poverty and inequality.
The package covers the majority of the most commonly used accessibility
measures (such as cumulative opportunities, gravity-based and floating
catchment areas methods), as well as the most frequently used inequality
and poverty metrics (such as the Palma ratio, the concentration and
Theil indices and the FGT family of measures).

## Installation

Expand All @@ -38,32 +39,29 @@ Development version:
remotes::install_github("ipeaGIT/accessibility")
```

## Basic usage
## Usage

This section aims to present a very brief overview of some of the
packages’ features. Fore more details please read the vignettes:

- [Introduction to **accessibility**: calculating accessibility
measures](https://ipeagit.github.io/accessibility/articles/accessibility.html)
- [Decay
functions](https://ipeagit.github.io/accessibility/articles/decay_functions.html)
- [Calculating accessibility inequality and
poverty](https://ipeagit.github.io/accessibility/articles/inequality_and_poverty.html)

To calculate accessibility levels, one simply needs a pre-calculated
travel matrix and some land use data. Below we showcase some of the
available functions:

``` r
library(accessibility)

# required data: a travel matrix and some land use data
data_dir <- system.file("extdata", package = "accessibility")
travel_matrix <- readRDS(file.path(data_dir, "travel_matrix.rds"))
land_use_data <- readRDS(file.path(data_dir, "land_use_data.rds"))

cost_closest <- cost_to_closest(
travel_matrix,
land_use_data,
opportunity = "schools",
travel_cost = "travel_time",
n = 1
)
head(cost_closest)
#> id travel_time
#> 1: 89a881a5a2bffff 29
#> 2: 89a881a5a2fffff 24
#> 3: 89a881a5a67ffff 28
#> 4: 89a881a5a6bffff 33
#> 5: 89a881a5a6fffff 32
#> 6: 89a881a5b03ffff 17

cum_cutoff <- cumulative_cutoff(
travel_matrix,
land_use_data,
Expand All @@ -80,22 +78,6 @@ head(cum_cutoff)
#> 5: 89a881a5a6fffff 6669
#> 6: 89a881a5b03ffff 37029

cum_interval <- cumulative_interval(
travel_matrix,
land_use_data,
opportunity = "jobs",
travel_cost = "travel_time",
interval = c(20, 30)
)
head(cum_interval)
#> id jobs
#> 1: 89a88cdb57bffff 7649
#> 2: 89a88cdb597ffff 21990
#> 3: 89a88cdb5b3ffff 22282
#> 4: 89a88cdb5cfffff 26841
#> 5: 89a88cd909bffff 14421
#> 6: 89a88cd90b7ffff 25699

grav <- gravity(
travel_matrix,
land_use_data,
Expand Down Expand Up @@ -129,52 +111,36 @@ head(fca)
#> 4: 89a88cdb5cfffff 0.5366707
#> 5: 89a88cd909bffff 0.4280401
#> 6: 89a88cd90b7ffff 0.5176583
```

sptl_avlblt <- spatial_availability(
travel_matrix,
land_use_data,
Calculating inequality and poverty levels is equally easy. Below we use
the previously calculated cumulative accessibility dataset to show some
of the available inequality and poverty functions:

``` r
palma <- palma_ratio(
cum_cutoff,
sociodemographic_data = land_use_data,
opportunity = "jobs",
travel_cost = "travel_time",
demand = "population",
decay_function = decay_exponential(decay_value = 0.1)
population = "population",
income = "income_per_capita"
)
head(sptl_avlblt)
#> id jobs
#> 1: 89a88cdb57bffff 186.0876
#> 2: 89a88cdb597ffff 140.0738
#> 3: 89a88cdb5b3ffff 736.5830
#> 4: 89a88cdb5cfffff 900.9284
#> 5: 89a88cd909bffff 0.0000
#> 6: 89a88cd90b7ffff 204.7962

bc <- balancing_cost(
travel_matrix,
land_use_data,
palma
#> palma_ratio
#> 1: 3.800465

poverty <- fgt_poverty(
cum_cutoff,
sociodemographic_data = land_use_data,
opportunity = "jobs",
travel_cost = "travel_time",
demand = "population"
population = "population",
poverty_line = 95368
)
head(bc)
#> id travel_time
#> 1: 89a881a5a2bffff 15
#> 2: 89a881a5a2fffff 13
#> 3: 89a881a5a67ffff 23
#> 4: 89a881a5a6bffff 7
#> 5: 89a881a5a6fffff 10
#> 6: 89a881a5b03ffff 6
poverty
#> FGT0 FGT1 FGT2
#> 1: 0.5745378 0.3277383 0.2218769
```

Please read the vignettes for more details on the usage:

- Introduction to **accessibility**: calculating accessibility
measures. Run
[`vignette("accessibility")`](https://ipeagit.github.io/accessibility/articles/accessibility.html).
- Decay functions. Run [`vignette("decay_functions", package =
"accessibility")`](https://ipeagit.github.io/accessibility/articles/decay_functions.html).
- Calculating accessibility inequality and poverty. Run
[`vignette("inequality_and_poverty", package =
"accessibility")`](https://ipeagit.github.io/accessibility/articles/inequality_and_poverty.html).

## Related work:

- [r5r](https://github.com/ipeaGIT/r5r): Rapid Realistic Routing with
Expand Down

0 comments on commit bfbb423

Please sign in to comment.