geo_distance: Calculate a distance matrix from an sf object

Description Usage Arguments Value Examples

View source: R/geo_distance.R

Description

Calculates a distance matrix from a list of geoids which correspond to either tract of block group ids for a given year. Alternatively calculates distance matrix for a sf data frame of polygons.

Usage

1
2
3
4
5
6
7
geo_distance(
  GEOIDs = NULL,
  year = 2018,
  geoid_sf = NULL,
  matrix = FALSE,
  adjust = TRUE
)

Arguments

GEOIDs

Character vector of GEOIDs of either tracts or block groups

year

The year, or endyear, of the ACS sample or Census. 2012 through 2018 are available for ACS and 2000 and 2010 for Census. Defaults to 2010.

geoid_sf

Alternative specification where an sf object is supplied and distances are calculated directly from that object

matrix

Logical whether to return a matrix rather than data frame.

adjust

Logical, adjust using Massey Denton specification.

Value

data frame or matrix indicating distance between geometry centroids in kilometers.

Examples

1
2
3
# get distances of all block groups in DC

geo_distance(geoid_sf = block_groups("DC", class = "sf"), matrix = TRUE)

nmmarquez/censeg documentation built on Sept. 12, 2020, 4:13 a.m.