Dear Jonathan,

Function get.snow() is not vectorized, i.e. it does not return a vector of the same length as its input. According to the help of app(), "The function should return a vector or matrix that is divisible by ncell(x).".

HTH,
Ákos Bede-Fazekas
Centre for Ecological Research
Hungary

2022.09.29. 5:27 keltezéssel, Thayn, Jonathan írta:
I keep getting the following message when using terra:app –– Error: [app] the 
number of values returned by 'fun' is not appropriate. I can’t figure out what 
I’m doing wrong. A sample code is below:




library(terra)
the.raster <- rast(ncol=4,nrow=4)
the.raster[] <- sample(0:65535,16)

get.snow <- function(j){
k <- as.numeric(intToBits(j)[10:11])
m <- k%*%1:2
return(m)
}

new.raster <- app(the.raster,get.snow)


        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to