Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plot_3d

Add a spatial object to a point cloud scene


Description

Add a RasterLayer object that represents a digital terrain model or a SpatialPointsDataFrame that represents tree tops to a point cloud scene. To add elements to a scene with a point cloud plotted with the function plot from lidR, the functions add_* take as first argument the output of the plot function (see examples), because the plot function does not plot the actual coordinates of the point cloud, but offsetted values. See function plot and its argument clear_artifacts for more details. It works only with rgl i.e. backend = "rgl" which is the default.

Usage

plot_dtm3d(dtm, bg = "black", clear_artifacts = TRUE, ...)

add_dtm3d(x, dtm, ...)

add_treetops3d(x, ttops, z = "Z", ...)

add_flightlines3d(x, flightlines, z = "Z", ...)

Arguments

dtm

An object of the class RasterLayer

bg

The color for the background. Default is black.

clear_artifacts

logical. It is a known and documented issue that 3D visualisation with rgl displays artifacts. The points and lines are inaccurately positioned in the space and thus the rendering may look false or weird. This is because rgl computes with single precision float. To fix this, the objects are shifted to (0,0) to reduce the number of digits needed to represent their coordinates. The drawback is that the objects are not plotted at their actual coordinates.

...

Supplementary parameters for surface3d or spheres3d.

x

The output of the function plot used with a LAS object.

ttops

A SpatialPointsDataFrame that contains tree tops coordinates.

z

character. The name of the attribute that contains the height of the tree tops or of the flightlines.

flightlines

A SpatialPointsDataFrame that contains flightlines coordinates.

Examples

LASfile <- system.file("extdata", "Topography.laz", package="lidR")
las = readLAS(LASfile, filter = "-keep_xy 273450 273600 5274450 5274600")

dtm = grid_terrain(las, algorithm = tin())
ttops <- find_trees(las, lmf(ws = 5))

plot_dtm3d(dtm)

x = plot(las)
add_dtm3d(x, dtm)
add_treetops3d(x, ttops)

## Not run: 
library(magrittr)
plot(las) %>% add_dtm3d(dtm) %>% add_treetops3d(ttops)

## End(Not run)

lidR

Airborne LiDAR Data Manipulation and Visualization for Forestry Applications

v3.1.2
GPL-3
Authors
Jean-Romain Roussel [aut, cre, cph], David Auty [aut, ctb] (Reviews the documentation), Florian De Boissieu [ctb] (Fixed bugs and improved catalog features), Andrew Sánchez Meador [ctb] (Implemented wing2015() for segment_snags()), Bourdon Jean-François [ctb] (Contributed to Roussel2020() for track_sensor()), Gatziolis Demetrios [ctb] (Implemented Gatziolis2019() for track_sensor())
Initial release
2021-03-11

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.