1

I am getting an error of "r: No ground points found. Impossible to compute a DTM." when running grid_terrain on a catalog. I think it is because my first tile is all water. Is there an option in LAScatalog to skip chunks based on class?

3
  • 1
    If the tile is full of classified water update to v2.2.0. This case is now handled in lidR.
    – JRR
    Commented Jan 13, 2020 at 19:20
  • Thank you! I was using 2.1.4 so I will upgrade now.
    – Ray J
    Commented Jan 13, 2020 at 19:50
  • I upgraded to v2.2.0, but it did not work for me unfortunately. In my case it does not make sense to include that tile at all so I have removed it. (note: in testing I did alter the file order to force the water tile to 2nd place in processing but was still unsuccessful).
    – Ray J
    Commented Jan 14, 2020 at 13:33

2 Answers 2

2

I had the same problem when normalizing some data. I found my way around using catalog_apply and a simple if else.

wd = "set your working directory"
ctg <- readLAScatalog(paste(wd,"data/",sep = ""), progress = TRUE)

ground_filter = function(chunk)
{
  las = readLAS(chunk)
  if (is.empty(las)) return(NULL)

  ground <- lasfilter(las, Classification == 2)               #filters ground points for each chunk              

  if (is.empty(ground))                                       #if no ground points are found returns NULL
    return(NULL)

  terrain <- grid_terrain(las, res= 1, tin())
  bbox <- raster::extent(chunk)
  terrain <- raster::crop(terrain, bbox)
  return(terrain)                                             #if ground points are found returns terrain
}

opt_chunk_buffer(ctg_0) <- 30                                 #needs to be > 0 to avoid edge artifacts
opt_output_files(ctg_0) <- paste(wd, "*_dtm", sep = "")       #export in directory

DTM <- catalog_sapply(ctg_0, ground_filter)
plot_dtm3d(DTM)

It might take longer because it first needs to filter the ground points but is convenient if you need to make a code that doesn´t need to stop (as catalog_select where you need to actually select files by hand). On the other hand, opt_stop_early bypasses files withouth ground points but might bypass other errors, as @JRR says. This code will skip those files with no ground points but will warn you of other errors.

1
  • This is a valid code, but a buffer of 0.5 is definitively too small.
    – JRR
    Commented Feb 13, 2020 at 9:56
1

Since lidR v2.2.0 you have at least four options for your specific case.

  1. The computation of a digital terrain model now considers points classified as water like ground points. So you should not encounter troubles if your water is classified. According to your comment I guess it is not.

  2. You also have the possibility to flag some tiles that won't be processed. These files are not removed, they are used to load the buffer of the neighboring processed files. You can do it interactively with catalog_select() or manually adding a column named processed into the LAScatalog.

    ctg <- catalog_select(ctg, method = "flag_unprocessed") 
    
  3. Indeed as you mentioned in comment you can simply remove the file from the catalog

    ctg <- ctg[-1,]
    
  4. You can bypass errors. I discourage this because if you have another error in another tile it will be bypassed as well without message.

    opt_stop_early(ctg) <- FALSE
    
1
  • Thank you for the quick reply. I've been using lidR for several weeks and looking forward to becoming more proficient at it.
    – Ray J
    Commented Jan 14, 2020 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.