hot_spot: Automatically calculate Local G hot spot intensity

View source: R/hot_spot.R

hot_spotR Documentation

Automatically calculate Local G hot spot intensity

Description

Function automatically calculates the Local G hot spot intensity measure for spatial points, spatial polygons, and single raster layers. Uses RANN for efficient nearest neighbor calculation (spatial points and single raster layers only); users can specify the number of neighbors (k). Users can specify the neighborhood style (see spdep::nb2listw) with default being standardized weight matrix (W).

Usage

hot_spot(
  insert,
  variable = NULL,
  style = "W",
  k = 9,
  remove_missing = TRUE,
  NA_Value = 0,
  include_Moran = FALSE
)

Arguments

insert

Spatial point, spatial polygon, or single raster layer object. Acceptable formats include sf, SpatialPolygonsDataFrame, SpatialPointsDataFrame, and RasterLayer.

variable

Column name or numeric vector containing the variable from which the local G statistic will be calculated. Must possess a natural scale that orders small and large observations (i.e. number, percentage, ratio and not model residuals).

style

Style can take values 'W', 'B', 'C', 'U', 'mimax', 'S' (see nb2listw). Character string.

k

Number of neighbors. Default is 9. Numeric.

remove_missing

Whether to calculate statistic without missing values. If FALSE, substitute value must be supplied to NA_Value.

NA_Value

Substitute for missing values. Default value is 0. Numeric.

include_Moran

Calculate local Moran's I statistics. Default is FALSE. Logical.

Value

If input is sf, SpatialPolygonsDataFrame or SpatialPointsDataFrame object, returns sf object with same geometries and columns as input, appended with additional column containing Local G estimates (LocalG). If input is RasterLayer object, returns RasterBrick object containing original values (Original) and Local G estimates (LocalG).

Examples

# Calculate Local G for sf point layer

## Not run: 
data(clea_deu2009_pt)
out_1 <- hot_spot(insert=clea_deu2009_pt, variable = clea_deu2009_pt$to1)
class(out_1)
plot(out_1["LocalG"])

## End(Not run)

# Calculate Local G for sf polygon layer (variable as numeric vector)

## Not run: 
data(clea_deu2009)
out_2 <- hot_spot(insert=clea_deu2009, variable = clea_deu2009$to1)
summary(out_2$LocalG)
plot(out_2["LocalG"])

## End(Not run)

# Calculate Local G for sf polygon layer (variable as column name)

## Not run: 
out_3 <- hot_spot(insert=clea_deu2009, variable = "to1")
summary(out_3$LocalG)
plot(out_3["LocalG"])

## End(Not run)

# Calculate Local G for sf polygon SpatialPolygonsDataFrame (variable as column name)

## Not run: 
out_4 <- hot_spot(insert=as(clea_deu2009,"Spatial"), variable = "to1")
summary(out_4$LocalG)
plot(out_4["LocalG"])

## End(Not run)

# Calculate Local G for RasterLayer
## Not run: 
data(gpw4_deu2010)
out_5 <- hot_spot(insert=gpw4_deu2010)
class(out_5)
terra::plot(out_5$LocalG)

## End(Not run)

zhukovyuri/SUNGEO documentation built on Nov. 5, 2023, 1:07 p.m.