I have 9 layer stacked DEM raster image in .tif format. I would like to smooth the image using focal()
function in raster
package in R.
img <- brick("/stack.tif")
img <- focal(img, w=matrix(1,4,4), fun=modal)
Getting this error:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘focal’ for signature ‘"RasterBrick"’
focal
over anything with more than one band. You have 9 bands. Do you want to run that operation on each band separately? Loop over the bands?