Commit eb35fca5 authored by Monnet Jean-Matthieu's avatar Monnet Jean-Matthieu

rasterMetrics supports RasterBrick objects

parent 49ba8654
......@@ -40,7 +40,7 @@
#' @export
rasterMetrics <- function(r, res=20, fun=function(x){data.frame(mean=mean(x$layer), sd=stats::sd(x$layer))}, output="raster")
{
if (class(r)=="RasterLayer")
if (is.element(class(r), c("RasterLayer", "RasterBrick")))
{
# convert to data.frame
st <- as.data.frame(raster::rasterToPoints(r))
......@@ -62,6 +62,6 @@ rasterMetrics <- function(r, res=20, fun=function(x){data.frame(mean=mean(x$laye
# add id column or coordinates
if(output=="raster")
{
raster::rasterFromXYZ(dummy, crs=projinfo)
raster::rasterFromXYZ(dummy, res=c(res, res), crs=projinfo)
} else {dummy}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment