# NOT RUN {
#- import the tree_line_plot dataset
file <- system.file("extdata", "tree_line_plot.laz", package="viewshed3d")
tls <- lidR::readLAS(file)
center <- c(0,0,2) # defines the scene center for the entire process
angle <- 1 # defines the angular resolution for the entire process
#- remove noise to avoid visibility estimates error
tls_clean <- viewshed3d::denoise_scene(tls,method="sd",
filter=6)
#- class ground and vegetation points
class <- lidR::classify_ground(tls_clean, lidR::csf(rigidness = 1L,
class_threshold = 0.2,
sloop_smooth = FALSE))
#- reconstruct the ground with the optimal resolution
recons <- viewshed3d::reconstruct_ground(data=class,
position = center,
ground_res = 0.05,
angular_res = angle,
method="knnidw",
full_raster = TRUE)
#- compute the visibility and store the output point cloud.
#- As the input file is a LAS object, the output
#- point cloud is also stored in a LAS file.
view.data <- viewshed3d::visibility(data = recons,
position = center,
angular_res = angle,
scene_radius = 17, # apply cut_oof distance
store_points = TRUE)
#- 3D plot with visible points in white and non-visible points in darkgrey
x=lidR::plot(view.data$points,color="Visibility",colorPalette = c("grey24","white"))
#- add animal position to the plot
position=data.frame(X=center[1],Y=center[2],Z=center[3])
lidR::add_treetops3d(x,sp::SpatialPointsDataFrame(position,position),
radius=0.2,col="red")
#- plot the visibility as function of distance
plot(view.data$visibility$r,view.data$visibility$visibility,
type="l",ylim=c(0,100),lwd=4)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab