reaggregate_raster: Extract all raster cell values that occur within each...

Description Usage Arguments Details Value

View source: R/Spatial_Functions.R

Description

This is similar to aggregate but with more control and information.

Usage

1
2
3
4
5
6
7
8
reaggregate_raster(
  x,
  coords,
  to_res = c(0, 0),
  with_weights = NULL,
  method = c("raster", "raster_con", "block"),
  tol = 0.01
)

Arguments

x

A raster::Raster object from which data are extracted.

coords

A numeric vector of length two or a matrix with two columns. The x and y coordinates of the center(s) of the rectangle(s).

to_res

A numeric vector of length two. The x- and y-extent of the rectangle(s).

with_weights

A logical value or NULL. If NULL, then code attempts to determine whether weights are required for the call to extract.

method

A character string. Selects the extraction method, see details.

tol

A numeric value. The absolute tolerance for deviation used if is.null(with_weights).

Details

Available extraction methods include

raster

Uses the function extract

raster_con

Uses the function extract2_Raster_SpatialPolygons. This is a modified version of extract where the 'connection' to the raster file is open for the entire extraction call and not re-opened/closed for each read event. This allows a massive speed-up which scales with the number of 'rectangles' to be extracted [not implemented].

block

Uses the function extract_blocks.

The weighted mean of the extracted values can be calculated as stats::weighted.mean(values, w = weights)

Value

A list of length corresponding to the number of rectangles. Each element is a list which contains three items each

N

An integer vector. The number of unique values within the rectangle for each layer of x.

values

A list of numeric vectors. The sorted unique values as vector for each layer.

weigths

A list of numeric vectors. The weights of the values for each layer.


Burke-Lauenroth-Lab/SoilWat_R_Wrapper documentation built on Aug. 14, 2020, 5:17 p.m.