MEW
MEW

Reputation: 1

lidR calculation or Rumple Index from points failing (and used to run)

I have used this code over the past couple years to calculate Rumple Index on millions of forested hectares. This week I cannot get it to process any lascatalog I point it to. Has there been an update to some other package that may be causing this error.

My error is this:

Error: The function is tested before starting processing the collection and failed with following error: Error in validityMethod(object): invalid extent: xmin >= xmax In addition: There were 15 warnings (use warnings() to see them)

warnings()

Warning messages:
1: In is.na(las) : is.na() applied to non-(list or vector) of type 'S4'
2: In min(x) : no non-missing arguments to min; returning Inf
3: In max(x) : no non-missing arguments to max; returning -Inf
4: In min(x) : no non-missing arguments to min; returning Inf
5: In max(x) : no non-missing arguments to max; returning -Inf
6: In C_highest(las, layout) : NAs introduced by coercion to integer range
7: In C_highest(las, layout) : NAs introduced by coercion to integer range
8: In min(x) : no non-missing arguments to min; returning Inf
9: In max(x) : no non-missing arguments to max; returning -Inf
10: In min(x) : no non-missing arguments to min; returning Inf
11: In max(x) : no non-missing arguments to max; returning -Inf
12: In min(x) : no non-missing arguments to min; returning Inf
13: In max(x) : no non-missing arguments to max; returning -Inf
14: In min(x) : no non-missing arguments to min; returning Inf
15: In max(x) : no non-missing arguments to max; returning -Inf

I have the most version of R (4.3.2) and R studio and lidR (4.04)

Here is a simplified version of the function and code

#=========================================
# Rumple Index Function using point cloud 
#=========================================

rumple_index_surface = function(cluster, res)
{
  las = readLAS(cluster)
  if (is.na(las)) return(NULL) #empty
  las <- filter_surfacepoints(las, 1)  #1
  rumple <- grid_metrics(las, ~rumple_index(X,Y,Z), res)
  bbox <- raster::extent(cluster)
  rumple <- raster::crop(rumple, bbox)
  return(rumple)
}


#-------------------------------------------------------
# Read in Normalized LAS data via creating a lascatalog
#-------------------------------------------------------
las.ctg.norm <- readLAScatalog(Ntile_path)

#----------------------------
#Set Options and filters
#----------------------------

opt_progress(las.ctg.norm) <- TRUE
opt_chunk_buffer(las.ctg.norm) <- 1
opt_filter(las.ctg.norm) <- "-keep_class 3 4 5 12 -drop_z_below 0.1 -drop_z_above 48" 
opt_select(las.ctg.norm) <- ("xyz") 

#-------------------------------------
#Save individual tile metrics to disk
#------------------------------------
opt_output_files(las.ctg.norm) <- file.path(Tile_metrics_path,"{*}_RI_GT0_metrics")

#-------------------
# Calculate Rumple
#-------------------
rumple <- catalog_apply(las.ctg.norm, rumple_index_surface, res = 25) #, .options = opt

I have tried it on small 6-tile lascatalog and other large lascatalogs that the code used to run with. I also just tried reading in one tile (as a las catalog) and it failed with the same error message

I know the raster pacakage has been discontinued. I tried to change the "extent" or "crop" calls to the terra equivalent but the same error message was provided. Can anyone offer some ideas to try. Thank you

Murray

Upvotes: 0

Views: 59

Answers (0)

Related Questions