geo_distance: Calculate and maps proximity metrics based on known point...

Description Usage Arguments Examples

View source: R/geo_distance.R

Description

The function examines proximity relative to user-specified point locations. The input data are i) a set of geographic units (e.g., census regions, health regions, etc.), and ii) the locations of places or events of interest. The function calculates the centroid of each geographic unit and the pairwise distances to all locations of interest. Proximity for each geographic unit is calculated as the average distance to the n nearest locations.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
geo_distance(
  data,
  geography_col,
  location_data,
  points_col,
  n_nearest = 3,
  levels = 5,
  plot_title = NA,
  legend_title = NA,
  plot = TRUE
)

Arguments

data

Geographic input data; must be a simple features (sf) shape object, e.g., imported by geo_import(). REQUIRED.

geography_col

Name of the data column containing the features, e.g., geographic units, to be plotted. REQUIRED.

location_data

Name of the dataset containing point locations to be used in distance calculations. Dataset must contain a column for location name or ID, titled 'id', and a pair of columns for the geographic coordinates of the points (e.g., longitude and latitude), titled 'x' and 'y'. Coordinate reference system (CRS) for these data is automatically transformed to match that of the input geographic data. If CRS is missing for location data, it is assumed to be WGS84. REQUIRED.

points_col

Name of the data column containing the label or value uniquely identifying each particular point location. REQUIRED.

n_nearest

number of point locations to use in calculation of proximity (average distance from centroid to n nearest locations of interest). Default is 3. If value is set at 1, proximity for each geographic unit will simply be the distance from the centroid to the nearest location. Must be specified as a positive integer value. OPTIONAL.

levels

Preferred number of shading categories representing proximity for each geographic regions. Default is 5. Generates equally sized categories of round numbers, resulting in a number of levels close to, but not necessarily exactly, the specified number of levels. OPTIONAL.

plot_title

Main title of plot. If omitted, no title is shown. OPTIONAL.

legend_title

Title of plot legend. If 'none', legend is removed. If no value is given, default title 'mean_distance" is used. OPTIONAL.

plot

TRUE (default) or FALSE, indicating whether or not a plot should be generated. If FALSE, a dataset is returned containing the calculated proximity values for each geographic unit (with new column 'mean_dist'). OPTIONAL.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Basic example of proximity analysis using default options and outputting a map ---------
geo_distance(data = my_geo_data,
  geography_col = region_data_column,
  location_data = my_point_location_data,
  legend_title = "Distance (m)",
  legend_position = "right",
  plot_title = "Average Distance to Point Locations")

# Proximity analysis using nearest 5 point locations and generating data output ----------
geo_distance(data = my_geo_data,
  geography_col = region_data_column,
  location_data = my_point_location_data,
  n_nearest = 5,
  plot = FALSE)

cpacc/geode documentation built on Feb. 13, 2022, 2:33 p.m.