Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. metrics<-function(z){Q75=quantile(z,probs=c(0.75))
  2.  
  3. aboveq75=sum(z>Q75)
  4.  
  5. dh75=aboveq75/length(z)
  6.  
  7. return(dh75)}
  8.  
  9. DH75<-grid_metrics(lid,~metrics(Z),res = 30)
  10.  
  11. #dependencies
  12. library(lidR)
  13. library(ggplot2)
  14. library(stats)
  15.  
  16. #specify file path
  17. infile <- 'path_to_your_cloud.las'
  18.  
  19. #read in las cloud
  20. las <- readLAS(infile)
  21.  
  22. #create density raster
  23. density_plot <- grid_density(las, res = 10)
  24.  
  25. #calculate 75th percentile point density
  26. Q75 = quantile(density_plot$point_density, probs = 0.75)
  27.  
  28. #filter raster based on value
  29. density_plot_Q75 <- density_plot[density_plot$point_density > Q75]
  30.  
  31. #plot unfiltered raster
  32. ggplot() +
  33. geom_raster(data = density_plot , aes(x = X, y = Y, fill = point_density)) +
  34. coord_quickmap()
  35.  
  36. #plot filtered raster
  37. ggplot() +
  38. geom_raster(data = density_plot_Q75 , aes(x = X, y = Y, fill = point_density)) +
  39. coord_quickmap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement