rasterizeWin | R Documentation |
Rasterize points using a circle (or ellipse) as moving window. For each raster cell, the points (x, y
) that fall within the window centered on that cell are considered. A function is used to compute a summary value (e.g. "mean") for the values (z
) associated with these points.
This can result in much smoother results compared to the standard rasterize
method.
## S4 method for signature 'SpatVector,SpatRaster'
rasterizeWin(x, y, field, win="circle", pars, fun, ..., cvars=FALSE,
minPoints=1, fill=NA, filename="", wopt=list())
## S4 method for signature 'data.frame,SpatRaster'
rasterizeWin(x, y, win="circle", pars, fun, ..., cvars=FALSE,
minPoints=1, fill=NA, filename="", wopt=list())
x |
SpatVector or matrix with at least three columns ((x, y) coordinates and a variable to be rasterized) |
y |
SpatRaster |
field |
character. field name in SpatVector |
win |
character to choose the window type. Can be "circle", "ellipse", "rectangle", or "buffer" |
pars |
parameters to define the window. If |
fun |
function to summarize the values for each cell. If |
... |
additional named arguments passed to |
minPoints |
numeric. The minimum number of points to use. If fewer points are found in a search ellipse it is considered empty and the fill value is returned |
fill |
numeric. value to use to fill cells with empty search areas |
cvars |
logical. When using multiple fields, should |
filename |
character. Output filename |
wopt |
list with additional arguments for writing files as in |
SpatRaster
rasterize
, rasterizeGeom
, interpNear
, interpIDW
r <- rast(ncol=100, nrow=100, crs="local", xmin=0, xmax=50, ymin=0, ymax=50)
set.seed(100)
x <- runif(50, 5, 45)
y <- runif(50, 5, 45)
z <- sample(50)
xyz <- data.frame(x,y,z)
r <- rasterizeWin(xyz, r, fun="count", pars=5)
rfuns <- c("count", "min", "max", "mean")
x <- lapply(rfuns, function(f) rasterizeWin(xyz, r, fun=f, pars=5))
names(x) <- rfuns
x <- rast(x)
#plot(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.