Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- metrics<-function(z){Q75=quantile(z,probs=c(0.75))
- aboveq75=sum(z>Q75)
- dh75=aboveq75/length(z)
- return(dh75)}
- DH75<-grid_metrics(lid,~metrics(Z),res = 30)
- > metrics(runif(1000))
- [1] 0.25
- > metrics(runif(12))
- [1] 0.25
- > metrics(runif(13))
- [1] 0.2307692
- LASfile <- system.file("extdata", "Megaplot.laz", package="lidR")
- las = readLAS(LASfile)
- Q75=quantile(las$Z,0.75)
- Q75
- ## 75%
- ## 19.32
- metrics <-
- function(z){
- aboveq75=sum(z>Q75)
- dh75=aboveq75/length(z)
- return(dh75)
- }
- > DH75<-grid_metrics(las,~metrics(Z),res = 3)
- > plot(DH75)
- #dependencies
- library(lidR)
- library(ggplot2)
- library(stats)
- #specify file path
- infile <- 'path_to_your_cloud.las'
- #read in las cloud
- las <- readLAS(infile)
- #create density raster
- density_plot <- grid_density(las, res = 10)
- #calculate 75th percentile point density
- Q75 = quantile(density_plot$point_density, probs = 0.75)
- #filter raster based on value
- density_plot_Q75 <- density_plot[density_plot$point_density > Q75]
- #plot unfiltered raster
- ggplot() +
- geom_raster(data = density_plot , aes(x = X, y = Y, fill = point_density)) +
- coord_quickmap()
- #plot filtered raster
- ggplot() +
- geom_raster(data = density_plot_Q75 , aes(x = X, y = Y, fill = point_density)) +
- coord_quickmap()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement