jbferet / biodivMapR

biodivMapR: an R package for α- and β-diversity mapping using remotely-sensed images
https://jbferet.github.io/biodivMapR/index.html
GNU General Public License v3.0
47 stars 13 forks source link

Error in functional diversity computation #31

Closed jofeggg closed 4 months ago

jofeggg commented 4 months ago

Hello,

I'm using the function map_functional_div to compute functional richness using a raster stack of 4 bands corresponding to functional traits (LAI, Cab...)

My tiff file was converted to ENVI BIL following the function:

raster2BIL( Raster_Path="H:/raster/trait_stack.tif", Sensor = "unknown", Output_Dir = FALSE, Convert_Integer = TRUE, Multiplying_Factor = 1, Multiplying_Factor_Last = 1, Mask = FALSE )

Then I run the functions:

Datadir <- "H:/raster" NameRaster <- 'trait_stack_bil' Input_Image_File <- file.path(Datadir,NameRaster) Output_Dir <- "H:/raster/funcdiv" TypePCA <- "SPCA" window_size <- 3

map_functional_div( Original_Image_File = Input_Image_File, Functional_File = FALSE, Selected_Features = FALSE, Output_Dir = Output_Dir, window_size, nbCPU = 8, MaxRAM = 0.5, FDmetric = c("FRic") )

And I get the error:

[1] "Compute functional metrics" compute Functional diversity in 8 chunks

Progress interrupted by subscriptOutOfBoundsError condition: subscript out of bounds Error in alphaSSD[[i]] : subscript out of bounds

Can you help me?

Thanks in advance.

Kind regards,

jofeggg commented 4 months ago

It was a problem with one of my traits that was taking values of 0 in all pixels when converting the raster to integer BIL without using the multiplying factor.

The function runs perfectly.

Sorry for the inconvenience.

Kind regards,

jbferet commented 4 months ago

ok, thank you for updating this issue! I will now close it. Best regards, jb