geo_calculate: Calculate and plot spatial statistics from geospatial and...

Description Usage Arguments Examples

View source: R/geo_calculate.R

Description

Given spatial input data, this function calculates and outputs spatial statistics and, optionally, a plot or map. Currently, the function will calculate the global (Moran's I) or local (Getis-Ord Gi*) spatial autocorrelation of a single spatial variable or rate. Rates are calculated automatically if a denominator variable is specified. Optional plots are Moran's I scatterplot for global spatial autocorrelation and a hotspot/coldspot map showing locations of significant local spatial autocorrelation.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
geo_calculate(
  data,
  var,
  statistic,
  denom,
  create_plot = TRUE,
  plot_title = NA,
  transparency = NA,
  hover_id,
  interactive = TRUE
)

Arguments

data

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

var

Column name of (numeric) variable to be analyzed. For calculation of rates, specify numerator with var and denominator with denom. REQUIRED.

statistic

Name of analysis to run on variable specified by 'var' (or rate specified by var/denom). Current options include 'global_ac' (global autocorrelation using Moran's I) or local_ac' (local autocorrelation using Getis-Ord Gi*). REQUIRED.

denom

Column name of (numeric) variable to be used as denominator in the calculation of raw rates. If included, numerator is assumed to be variable specified by var argument and rates are calculated and analyzed automatically. OPTIONAL.

create_plot

TRUE (default) or FALSE. Indicating whether or not plot/map should be generated with statistical output. OPTIONAL.

plot_title

Main title of plot. If omitted, no title is shown. Applies only to static image maps. OPTIONAL.

transparency

value between 0 and 1 (default = 0.6) that defines transparency of map colours, from transparent (0) to opaque (1). Intermediate values allow more or less visibility of underlying (reference) layers in interactive maps. OPTIONAL.

hover_id

Name of the data column containing the label or value to be shown when hovering over a particular geographic unit. For interactive maps only. Default is the name or value given in specified var column (or the rate, if denom is also specified). OPTIONAL.

interactive

TRUE (default) or FALSE. Indicating whether map should be generated as an interactive view or as a static image. OPTIONAL.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Test for global spatial autocorrelation and generation of Moran's I scatterplot -----
geo_calculate(data = my_geo_data,
   var = rate_column_name,
   statistic = 'global_ac',
   create_plot = TRUE)

# Calculate local spatial autocorrelation and generate hotspot-coldspot map -----
# (Event rates are calculated automatically as numerator (var) / denominator (denom))
geo_calculate(data = my_geo_data,
   var = event_count_column,
   denom = pop_size_column,
   statistic = 'local_ac',
   create_plot = TRUE)

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