allocate | R Documentation |
allocate
takes x
and y
coordinates and values from data frame, which is describing point spatial data, and puts them into cells of raster. The certain function (either mean value, sum of values, number of points) is applied for >0 points inside of the exact cell borders.
allocate(vec, coords = c("x", "y"), nodata = NA, attr = ".+", fun = c("mean", "sum", "n"),
cellsize = NA, resetGrid = FALSE, verbose = FALSE)
vec |
|
coords |
Character of length 2. Colums names, which contain coordinates of data points. Raster bands are not produced for specified columns. For misreference of coordinate columns, the attempt to find more appropriate coordinate columns is taken. |
fun |
Character keyword of function, which is applied to value of points, which are dropped into the same cell. Valid values are |
nodata |
Numeric of length 1. This value used to mark |
attr |
Pattern in the format of regular expressions, which is used to select required columns in data frame. By default ( |
cellsize |
Numeric. Desired size of cell in the raster grid. Used only when source data are not in regular grid. Default is |
resetGrid |
Logical. If |
verbose |
Logical. Some output in console. Primarily for debug purposes. |
Here fun
differs from R-styled fun
in such functions as *apply
, aggregate
.
It was refused “rasterize” for function name to distinguish with rasterize
in the package raster
Object of class ursaRaster
Nikita Platonov platonov@sevin.ru
session_grid(NULL)
g1 <- session_grid(regrid(session_grid(),mul=1/10))
n <- 1000
x <- with(g1,runif(n,min=minx,max=maxx))
y <- with(g1,runif(n,min=miny,max=maxy))
z <- with(g1,runif(n,min=0,max=10))
da <- data.frame(x=x,y=y,value=z)
res <- c(mean=allocate(da,fun="mean")
,mean_=NA
,sum=allocate(da,fun="sum")
,count=allocate(da,fun="n"))
res["mean_"]=res["sum"]/res["count"]
print(res)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.