Open jofeggg opened 4 days ago
Sorry for bothering you again with an error that i could fixe myself. That was caused by having attached effects and survival package.
I would like to take this opportunity to comment on another problem.
I am working with UAV orthomosaics, and when these do not have a rectangular shape, that is, they have complex shapes, the raster2bil function does not work correctly in the nodata areas and creates very low values in those areas (instead of -inf they are -3.3999999521444E+38), and therefore later when creating the PCA images, they are wrong (with a unique value). Maybe it is a problem with the perform_PCA function. When I clip the orthomosaics, all is working as expected.
How can I solve this?
EDIT: If I change the -Inf value in the HDR file by -3.3999999521444E+38, the PCA bands are properly produced and spectral diversity metrics
EDIT2: this workaround doesn't work when computing funtional diversity metrics without PCA. I get the error:
Progress interrupted by simpleError condition: Received error code 1 from qhull. Qhull error: QH6013 qhull input error: input is less than 5-dimensional since it has the same x coordinate
While executing: | qhull Fx TO 'vert.txt' FA Qt Options selected for Qhull 2015.2.r 2016/01/18: run-id 1891503203 Fxtremes TOutput-file vert.txt FArea-total Qtriangulate Qxact_merge _zero-centrum _max-width 0 Error-roundoff 4e+25 _one-merge 4.4e+26 _near-inside 2.2e+27 Visible-distance 2.4e+26 U-coplanar-distance 2.4e+26 Width-outside 4.8e+26 _wide-facet 1.4e+27
Error in geometry::convhulln(spectraits, "Fx TO 'vert.txt'", output.options = "FA") : Received error code 1 from qhull. Qhull error: QH6013 qhull input error: input is less than 5-dimensional since it has the same x coordinate
While executing: | qhull Fx TO 'vert.txt' FA Qt Options selected for Qhull 2015.2.r 2016/01/18: run-id 1891503203 Fxtremes TOutput-file vert.txt FArea-total Qtriangulate Qxact_merge _zero-centrum _max-width 0 Error-roundoff 4e+25 _one-merge 4.4e+26 _near-inside 2.2e+27 Visible-distance 2.4e+26 U-coplanar-distance 2.4e+26 Width-outside 4.8e+26 _wide-facet 1.4e+27
When using rectangular orthomosaics with an ENVI file, all works ok. I think that all the problem is with the raster2BIL function.
When I execute the map_spectral_species function, I get the following error:
Error in tweak.function(strategy, ..., penvir = penvir) : Trying to use non-future function ‘survival::cluster’: function (x) { ... }
Here is my complete workflow (all runs perfectly until map_spectral_species):
setwd("D:/_prueba_MS/RTM")
B1 <- raster("vuelo1_B1_blue_cliplarge.tif") B2 <- raster("vuelo1_B2_green_cliplarge.tif") B3 <- raster("vuelo1_B3_red_cliplarge.tif") B4 <- raster("vuelo1_B4_rededge_cliplarge.tif") B5 <- raster("vuelo1_B5_nir_cliplarge.tif")
stack <- stack(B1,B2,B3,B4,B5) raster::writeRaster(stack, filename="D:/_prueba_MS/RTM/band_stack", overwrite=TRUE, format="GTiff")
raster2BIL( Raster_Path="D:/_prueba_MS/RTM/band_stack.tif", Sensor = "unknown", Output_Dir = "D:/_prueba_MS/RTM/", Convert_Integer = FALSE, Multiplying_Factor = 1, Multiplying_Factor_Last = 1, Mask = FALSE )
mask <- raster("ndvi_mask_cliplarge.tif") raster::writeRaster(mask, filename="D:/_prueba_MS/RTM/band_mask", overwrite=TRUE, datatype="INT1S", format="GTiff")
raster2BIL( Raster_Path="D:/_prueba_MS/RTM/band_mask.tif", Sensor = "unknown", Output_Dir = "D:/_prueba_MS/RTM/", Convert_Integer = TRUE, Multiplying_Factor = 1, Multiplying_Factor_Last = 1, Mask = TRUE )
Datadir <- "D:/_prueba_MS/RTM" NameRaster <- 'band_stack' Input_Image_File <- file.path(Datadir,NameRaster)
NameRaster_mask <- 'band_mask' Input_Mask_File <- file.path(Datadir,NameRaster_mask)
Output_Dir <- "D:/_prueba_MS/RTM/biodivMapR_spectraldiv_RESULTS" TypePCA <- "SPCA" window_size <- 20 nbCPU <- 8 MaxRAM <- 1
Continuum_Removal <- FALSE FilterPCA <- FALSE nbclusters <- 20
PCA_Output <- perform_PCA(Input_Image_File = Input_Image_File, Input_Mask_File = Input_Mask_File, Output_Dir = Output_Dir, TypePCA = TypePCA, FilterPCA = FilterPCA, nbCPU = nbCPU, MaxRAM = MaxRAM, Continuum_Removal = Continuum_Removal)
path of the raster resulting from dimensionality reduction
PCA_Files <- PCA_Output$PCA_Files
path for the updated mask
Input_Mask_File <- PCA_Output$MaskPath
Select components from the PCA/SPCA/MNF raster
Sel_PC = path of the file where selected components are stored
Sel_PC <- select_PCA_components(Input_Image_File = Input_Image_File, Output_Dir = Output_Dir, PCA_Files = PCA_Output$PCA_Files, TypePCA = PCA_Output$TypePCA, File_Open = TRUE)
Kmeans_info <- map_spectral_species(Input_Image_File = Input_Image_File, Input_Mask_File = Input_Mask_File, Output_Dir = Output_Dir, SpectralSpace_Output = PCA_Output, nbclusters = nbclusters, nbCPU = nbCPU, MaxRAM = MaxRAM)