Skip to content
Prev 23801 / 29559 Next

Needing to speed up a process involving calc() and cover() raster functions

Hi Mathieu,

your question is rather difficult to understand. From the context I 
gather that you are referring to the results of the sam() function from 
RStoolbox.
Further, I assume you want to threshold each layer for a maximum 
spectral angle  and then find the class with the minimum spectral angle 
per pixel, right?

In this case you could do:

out   <- stack(lapply(1:nlayers(classified), function(i) 
clamp(classified[[i]], upper = threshs[[i]], useValues = FALSE)))
class <- which.min(out)

Cheers,
Benjamin
On 22.12.2015 10:57, Mathieu Rajerison wrote: