GeoMOER / moer-mpg-upscaling

MIT License
0 stars 0 forks source link

moer_mpg_upscaling_unit04_Lidar #1

Open ecoinfo-netra opened 2 years ago

GimpelMa commented 2 years ago

Hi, I get the Error Error in validityMethod(object) : Invalid wavelength vector for spectra, when I want to start the lapply-function for 2015 in EX | Data preparation -> Hyperspectal data -> #lets calculate vegetation indices by making a speclib. The lapply for 2016 works like a charm.

I already replaced the three files from the minor_correction folder. I can't find what is causing the problem. Until that point, everything worked just fine so that I only had to change paths.

Any ideas?

Greetings, Mandy

ecoinfo-netra commented 2 years ago

Hi Mandy, I also face this problem sometimes, here is what may work. Update your packages or restart R, make sure that you are use using the right plots for 2015. Anyhow I am pasting the code again here (i ran it now again, it is definitely working) vi <- "NDVI" library(future) future::plan(multisession, workers = 2L)

vi_stats_2015 <- lapply(seq(length(list_ext_intersection_lidar_hs1)), function(i){

hy_2015 <- speclib(raster::brick(list_ext_intersection_lidar_hs1[[i]]), wavelength_2015) hy_indices_2015 <- vegindex(hy_2015, index = vi) hy_indices_2015 <- hy_indices_2015@spectra@spectra_ra names(hy_indices_2015) <- vi

writeRaster(hy_indices_2016, filename = paste0(file.path(wd, "output/veg_indices_raster",hy_names_2016[i], "_vegindex.tif")))

vi_means_2015 <- as.data.frame(t(cellStats(hy_indices_2015, stat = "mean", na.rm = TRUE))) vi_sd_2015 <- as.data.frame(t(cellStats(hy_indices_2015, stat = "sd", na.rm = TRUE)))

vi_mean <- data.frame(PlotID = hy_names_2015[i], vi_means_2015) names(vi_mean)[2] <- paste(names(vi_mean[2]), "_mean", sep = "")

vi_sd <- data.frame(PlotID = hy_names_2015[i], vi_sd_2015) names(vi_sd)[2] <- paste(names(vi_sd[2]), "_sd", sep = "")

vi_table <- left_join(vi_mean, vi_sd, by = "PlotID")

return(vi_table)

})

vi_table_2015 <- do.call(rbind, vi_stats_2015)

seegerkonstantin commented 2 years ago

Hi, when I run the code: “ctg_aoi <- filter_poi(classify_noise(ctg_aoi, sor(15,7)), Classification != 18) “ I get the error “Error: Argument is not a LAS object” . This error appears from the filter_poi function and I think it doesnot work because the data is a lascatalog object and not a LAS object as I tested it out with a single file and it worked. How can I solve this problem?

Not sure if this is related but I get 28 warnings from the “classify_noise” part of this code line all saying “Invalid data: ScanAngleRank greater than 90 degrees”.

Konstantin

ecoinfo-netra commented 2 years ago

Hi Konstantin, thanks for pointing out. The error appears because filter_poi is not working on a las catalog. I have re written the code and divided into two parts now

  1. classifying points with noise
  2. filtering based on a adapted filter_poi function

remove noise

ctg_aoi <- readLAScatalog(list.files(aoi_path, full.names = T))

function

filter_poi_noise = function(las) { las <- readLAS(las) # Read the LAScluster if (is.empty(las)) return(NULL) # Exit early (see documentation)

las <- filter_poi(las, Classification != 18)
return(las) # Return the filtered point cloud }

opt_output_files(ctg_aoi) <- paste0(aoi_path,"/{*}_noise") ctg_aoi <- classify_noise(ctg_aoi, sor(15,7))

denoise using function filter_poi_noise

opt_output_files(ctg_aoi) <- paste0(aoi_path, "/{*}_denoise") ctg_aoi <- catalog_apply(ctg_aoi, filter_poi_noise)

for invalid scan angle

All I can suggest now is use the latest version of rlas package. I will try and find a better solution if it wont work. Here is the link for scan angles - https://github.com/r-lidar/lidR/issues/219

SophiaJust commented 2 years ago

Hi, I think in the first chunk dealing with the hyperspectral data, when defining the two lists "flight_1_plot_list" and "flight_two_plot_list", there is one plot missing - fpd0

Do you know whether that plot belongs to the first or second flight?

ecoinfo-netra commented 2 years ago

Hi Sophia, I think I did not include it as it was missing from the lidar files. In all, we are using 63 plots after removing missing data.

GimpelMa commented 2 years ago

Hi Netra, I don't know what the problem was, but now, with the code you provided above as a comment, the code for 2015 workded well.

Mandy

GimpelMa commented 2 years ago

Hi, I have a question regarding the source citations for the data you provided (LiDAR, Hyperspectral, DEM, pH, etc.). Where can I find sources for this or is it enough to state this as Kili Research Group?

Mandy

ecoinfo-netra commented 2 years ago

Hi Mandy,

You can keep the species data, lidar and hyperspectral sources as Kili ones. For dem the source is ASTER (https://asterweb.jpl.nasa.gov/gdem.asp) pH is derived from https://www.isda-africa.com/isdasoil/ temperature is from worldclim.

Hope it helps.

Quoting Mandy Gimpel @.***>:

Hi, I have a question regarding the source citations for the data
you provided (LiDAR, Hyperspectral, DEM, pH, etc.). Where can I find
sources for this or is it enough to state this as Kili Research Group?

Mandy

-- Reply to this email directly or view it on GitHub: https://github.com/GeoMOER/moer-mpg-upscaling/issues/1#issuecomment-1157502688 You are receiving this because you authored the thread.

Message ID: @.***>

-- Netra Bhandari