actiwalkability provides helpers for querying the EPA
Walkability Index and working with Census GEOID/FIPS identifiers.
Core entry points:
ww_epa_walkability() for querying the EPA Walkability
Index ArcGIS layerww_fips15() and ww_fips12() for composing
Census FIPS/GEOID stringsYou can install actiwalkability from GitHub with:
# install.packages("remotes")
remotes::install_github("jhuwit/actiwalkability")The EPA index is reported for Census block groups. Start with an address lookup that contains 12-character, Census 2010 block-group GEOIDs; keep these identifiers as character values so leading zeroes are retained.
library(actiwalkability)
addresses <- dplyr::tibble(
address_id = c("address_1", "address_2", "address_3"),
geoid = c("240054519002", "240054026041", "245102303002")
)
knitr::kable(addresses)| address_id | geoid |
|---|---|
| address_1 | 240054519002 |
| address_2 | 240054026041 |
| address_3 | 245102303002 |
If state, county, tract, and block identifiers are available instead,
create a block-group GEOID with acti_fips12():
acti_fips12(state = 24, county = 510, tract = 60400, block = 2002)
#> [1] "245100604002"Query the EPA layer with the unique GEOIDs. This is a live service
request; the chunk is cached so subsequent README renders
reuse the saved result.
walkability <- acti_epa_walkability(
unique(addresses$geoid),
geometry = FALSE,
fields = c("GEOID10", "NatWalkInd")
)knitr::kable(dplyr::select(
as.data.frame(walkability),
GEOID10, NatWalkInd, cat_walk_index
))| GEOID10 | NatWalkInd | cat_walk_index |
|---|---|---|
| 240054519002 | 4.166667 | [1,5.75] |
| 245102303002 | 14.333333 | (10.5,15.2] |
| 240054026041 | 8.666667 | (5.75,10.5] |
Join the returned index values back to the address lookup:
address_walkability <- dplyr::left_join(
addresses,
walkability,
by = c("geoid" = "GEOID10")
)
knitr::kable(dplyr::select(
address_walkability,
address_id, geoid, NatWalkInd, cat_walk_index
))| address_id | geoid | NatWalkInd | cat_walk_index |
|---|---|---|---|
| address_1 | 240054519002 | 4.166667 | [1,5.75] |
| address_2 | 240054026041 | 8.666667 | (5.75,10.5] |
| address_3 | 245102303002 | 14.333333 | (10.5,15.2] |
geometry = TRUE also returns the EPA block-group
polygons (as an sf object, which requires the ‘sf’
package), so the index can be mapped directly. The hard-coded plot
extent provides the wider Baltimore, Maryland context. This query is
cached in the README.
walkability_map <- acti_epa_walkability(
unique(addresses$geoid),
geometry = TRUE,
fields = c("GEOID10", "NatWalkInd")
)
label_points <- sf::st_coordinates(
sf::st_transform(sf::st_point_on_surface(walkability_map), 4326)
)
#> Warning: st_point_on_surface assumes attributes are constant over geometries
walkability_labels <- dplyr::mutate(
sf::st_drop_geometry(walkability_map),
longitude = label_points[, "X"],
latitude = label_points[, "Y"]
)
ggplot2::ggplot() +
ggplot2::geom_sf(
data = walkability_map,
ggplot2::aes(fill = NatWalkInd),
colour = "white"
) +
ggrepel::geom_text_repel(
data = walkability_labels,
ggplot2::aes(longitude, latitude, label = GEOID10),
seed = 2026,
min.segment.length = 0,
size = 3
) +
ggplot2::scale_fill_viridis_c(name = "Walkability\nindex") +
ggplot2::coord_sf(
crs = 4326,
default_crs = 4326,
xlim = c(-77, -76.1),
ylim = c(39, 39.7),
expand = FALSE
) +
ggplot2::labs(
title = "Example Census block groups in Baltimore, Maryland",
subtitle = "EPA National Walkability Index"
) +
ggplot2::theme_minimal()
This work was supported by NIH grant P30AG021334 and the Johns Hopkins Older Americans Independence Center (OAIC) Pepper Center grant.