Learn R Programming

sfcentral (version 0.1.0)

st_sd_distance: Standard deviation distance calculator

Description

Calculate the spatial deviaction distance from a points sf dataset.

Usage

st_sd_distance(.x, centre = NULL, weights = NULL, ...)

# S3 method for sfg st_sd_distance(.x, centre = NULL, weights = NULL, ...)

# S3 method for sf st_sd_distance(.x, centre = NULL, weights = NULL, ...)

# S3 method for sfc st_sd_distance(.x, centre = NULL, weights = NULL, ...)

Value

A sf "POLYGON" with atributes:

  • radius (standard deviation distance)

  • area surrounding,

  • perimeter,

  • center coordinates,

  • weigted indicator if weights were used or not in the calculaton.

Arguments

.x

sf points 2D or 3D

centre

One central point of class sf, sfc, numeric (length 2), matrix (2 col, 1 row), data.frame (2 col, 1 row), or list (length 2). Default NULL, means a calculation of the st_central_point() from .x localities.

weights

Numeric. Same length as number of points in .x.

...

other parameters for sf::st_distance()

Author

Gabriel Gaona

Examples

Run this code
  requireNamespace("ggplot2", quietly = TRUE)
  library(sf, quietly = TRUE)
  library(ggplot2)
  bbx <- matrix(c(697047,9553483,
                  696158,9560476,
                  700964,9561425,
                  701745,9555358),
                byrow = TRUE,
                ncol = 2)
  bbx <- st_multipoint(bbx)
  bbx <- st_cast(bbx,"POLYGON")
  bbx <- st_sfc(bbx, crs = 31992)
  set.seed(1234)
  points <- st_sf(geometry = st_sample(bbx, 100))
  SDD <- st_sd_distance(points)
  ggplot() +
    geom_sf(data = SDD, fill = NA, color = "darkolivegreen") +
    geom_sf(data = points, color = "steelblue", size = 0.5)

Run the code above in your browser using DataLab