Learn R Programming

inlabru (version 2.3.1)

bru_fill_missing: Fill in missing values in Spatial grids

Description

Computes nearest-available-value imputation for missing values in space

Usage

bru_fill_missing(
  data,
  where,
  values,
  layer = NULL,
  selector = NULL,
  batch_size = 500
)

Arguments

data

A SpatialPointsDataFrame, SpatialPixelsDataFrame, or a SpatialGridDataFrame containg data to use for filling

where

A, matrix, data.frame, or SpatialPoints or SpatialPointsDataFrame, containing the locations of the evaluated values

values

A vector of values to be filled in where is.na(values) is TRUE

layer, selector

Specifies what data column or columns from which to extract data, see component() for details.

batch_size

Size of nearest-neighbour calculation blocks, to limit the memory and computational complexity.

Value

An infilled vector of values

Examples

Run this code
# NOT RUN {
if (bru_safe_inla()) {

points <-
  sp::SpatialPointsDataFrame(
    matrix(1:6, 3, 2),
    data = data.frame(val = c(NA, NA, NA))
  )
input_coord <- expand.grid(x = 0:7, y = 0:7)
input <- 
  sp::SpatialPixelsDataFrame(
    input_coord,
    data = data.frame(val = as.vector(input_coord$y))
  )    
points$val <- bru_fill_missing(input, points, points$val)
print(points)

}
# }

Run the code above in your browser using DataLab