Stack Rasters to carry on a Mann-Kendall analysis

Hi!

I have the following code and I found some problems:

library(sp)
library(raster)
library(Kendall)
library(spatialEco)

setwd("C:\NDVI_prueba")
rlist=list.files(pattern=".tif$", full.names=T)
rasters=stack(rlist)
rasters

fun_kendall <- function(x){ return(unlist(MannKendall(x)))}
kendall_result <- calc(rasters,fun_kendall)
writeRaster(kendall_result$tau, filename = "C:\NDVI_prueba\NDVI_STACK_tau.tif", format="GTiff", overwrite=TRUE)
writeRaster(kendall_result$sl, filename = "C:\NDVI_prueba\NDVI_STACK_p-value.tif", format="GTiff", overwrite=TRUE)

It works stacking few images (5 in total), it generates the two rasters but does not work with 620 images (stack).

Does anyone know why?

Original post is here

You should probably try to avoid creating multiple posts for interrelated issues.

For this one you should post the error that R is throwing so that we can better help ya.

1 Like

My apologies.

The error that R is throwing it is the next:

WARNING: Error exit, tauk2. IFAULT = 12

It gives this error repeated so many times. By the way, gives me the same error if I stack 620 images or 5 images but only creates the resultant raster with 5 images stack.

Thank you

Strange. You don't get any other errors when running on the stack of 620 vs the 5? I imagine you might run into problems with available memory trying to stack that many rasters.

This message you're seeing is a warning rather than an error (hence the output still working for your stack of 5). A quick google search suggests that this is related to the number of observations. So if it's not working on your stack of 620 that suggests to me that it's another issue separate from this warning.

Is the only error. I guess that are memory issues because with few images (stack) I am able to do it.

In case that I change the way and I use the following code:

library(sp)
library(raster)
library(Kendall)
library(spatialEco)

setwd("C:\\NDVI_250m_ALL_IMAGES")
rlist=list.files(pattern=".tif$", full.names=T)
rasters=stack(rlist)
rasters

logo.trend <- raster.kendall(rasters, p.value=TRUE, confidence=TRUE)
   names(logo.trend) <- c("slope","p.value","LCI","UCI")
     plot(logo.trend)

How can I obtain a raster (.tif) just of the "p.value" to open it with a GIS software?

1 Like