point2rast: Points to raster nearest neighbour interpolation

View source: R/interpolate.R

point2rastR Documentation

Points to raster nearest neighbour interpolation

Description

Points to raster nearest neighbour interpolation

Usage

point2rast(
  data,
  spatobj,
  loc = c("x", "y"),
  cellsize,
  nnmax = 4,
  as = c("SpatRast", "SpatVect")
)

Arguments

data

Vector, dataframe, or spatial (class: 'Spatial' or 'sf') input data to use for interpolation

spatobj

Spatial object used to create extent for output raster

loc

Vector of coordinate variable names or matrix of coordinates

cellsize

Output raster cell size

nnmax

Nearest neighbour maximum neighbours used for interpolation

as

Output as raster 'SpatRast' or vector 'SpatVect'

Value

A terra SpatRaster or SpatVector object

Author(s)

Travis Tai

Examples

## Not run: 
dat <- data.frame(x = runif(5, 0, 10), y = runif(5, 0, 10), var = rnorm(5))
extent <- st_bbox(c(xmin = 0, ymin = 0, xmax= 10, ymax = 10),crs = NA)
output <- point2rast(dat, extent, loc = c("x","y"), cellsize = 0.5, nnmax = 2, as = "SpatRast")
output
plot(output)

## End(Not run)

pbs-assess/PACea documentation built on April 17, 2025, 11:36 p.m.