LiDARForestStand: 3D stand visualization of LiDAR-derived individual trees

Description Usage Arguments Value Author(s) References Examples

View source: R/LiDARForestStand.R

Description

Draws a 3D scatterplot for individual trees detected from Lidar data.

Usage

1
2
3
4
LiDARForestStand(crownshape = c("cone", "ellipsoid", "halfellipsoid",
                "paraboloid", "cylinder"), CL = 4, CW = 8, HCB = 10, 
                  X = 0, Y = 0, dbh = 0.3, crowncolor = "forestgreen", 
                 stemcolor = "chocolate4", resolution="high", mesh=TRUE)

Arguments

crownshape

shape of individual tree crown: "cone", "ellipsoid","halfellipsoid", "paraboloid" or "cylinder". Default is "halfellipsoid".

CL

crown length.

CW

crown diameter.

HCB

height at canopy base.

X

x-coordinate.

Y

y-coordinate.

dbh

diameter at breast height (1.73 m).

crowncolor

crown color.

stemcolor

stem color.

resolution

crown resolution: "low", "medium" and "high".

mesh

Logical, if TRUE (default) returns a tree crown mesh model, and if FALSE returns a tree crown line mode.

Value

Returns a 3-D scatterplot of the individual trees as identified automatically from the LiDAR.

Author(s)

Carlos Alberto Silva and Remko Duursma. Uses code by Remko Duursma (Maeswrap package,see "Plotstand").

References

https://maespa.github.io/

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#=======================================================================#
# EXAMPLE 01: Plotting single trees
#=======================================================================#

# cone crown shape
library(rgl)
open3d() 
LiDARForestStand(crownshape = "cone", CL = 10, CW =7, 
           HCB = 5, X =0, Y = 0, dbh = 0.4, crowncolor = "forestgreen", 
           stemcolor = "chocolate4", resolution="high", mesh=TRUE) 
                       
# ellipsoid crown shape 
open3d()
LiDARForestStand(crownshape = "ellipsoid", CL = 10, CW =7, 
           HCB = 5, X =0, Y = 0, dbh = 0.4, crowncolor = "forestgreen", 
           stemcolor = "chocolate4", resolution="high", mesh=TRUE) 
                       
# halfellipsoid crown shape 
open3d()
LiDARForestStand(crownshape = "halfellipsoid", CL = 10, CW =7, 
           HCB = 5, X =0, Y = 0, dbh = 0.4, crowncolor = "forestgreen", 
           stemcolor = "chocolate4", resolution="high", mesh=TRUE) 
                       
# paraboloid crown shape 
open3d()
LiDARForestStand(crownshape = "paraboloid", CL = 10, CW =7, 
           HCB = 5, X =0, Y = 0, dbh = 0.4, crowncolor = "forestgreen", 
           stemcolor = "chocolate4", resolution="high", mesh=TRUE)

# cylinder crown shape 
open3d()
LiDARForestStand(crownshape = "cylinder", CL = 10, CW =7, 
           HCB = 5, X =0, Y = 0, dbh = 0.4, crowncolor = "forestgreen", 
           stemcolor = "chocolate4", resolution="high", mesh=TRUE)
                       
# Set the shape=FALSE 
open3d()
LiDARForestStand(crownshape = "paraboloid", CL = 10, CW =7, 
           HCB = 5, X =0, Y = 0, dbh = 0.4, crowncolor = "forestgreen", 
           stemcolor = "chocolate4", resolution="high", mesh=FALSE)

#=======================================================================#
#EXAMPLE 02: Plotting a forest plantation stand in virtual 3-D space
#=======================================================================#

# Set the dimensions of the displayed forest stand
xlength<-30 # x length
ylength<-20 # y length

# Set the space between trees
sx<-3 # x space length
sy<-2 # y space length

# Tree location grid
XYgrid <- expand.grid(x = seq(1,xlength,sx), y = seq(1,ylength,sy))

# Get the number of trees
Ntrees<-nrow(XYgrid)

# Plot a virtual Eucalyptus forest plantation stand using the halfellipsoid tree crown shape

# Set stand trees parameters
meanHCB<-5  # mean of the height at canopy base
sdHCB<-0.1  # standard deviation of the height at canopy base
HCB<-rnorm(Ntrees, mean=meanHCB, sd=sdHCB) # height at canopy base
CL<-HCB     # tree crown height
CW<-HCB*0.6 # tree crown diameter

open3d()    # open a rgl window

# Plotting the stand
for( i in 1:Ntrees){
 LiDARForestStand(crownshape = "halfellipsoid", CL = CL[i], CW = CW[i], 
             HCB = HCB[i], X = XYgrid[i,1], Y = XYgrid[i,2], dbh = 0.4, 
             crowncolor = "forestgreen", stemcolor = "chocolate4", 
             resolution="high", mesh=TRUE) 
}
                           
# Add other plot parameters
axes3d(c("x-", "x-", "y-", "z"), col="gray")       # axes
title3d(xlab = "X Coord", ylab = " Y Coord", zlab = "Height", col="red") # title
planes3d(0, 0, -1, 0.001, col="gray", alpha=0.7)   # set a terrain plane


# Plotting a virtual single-species forest plantation stand using "cone" tree crown shape

# Set parameters f trees growing within the virtual stand
meanHCB<-3  # mean of the height at canopy base
sdHCB<-0.1  # standard deviation of the height at canopy base
HCB<-rnorm(Ntrees, mean=meanHCB, sd=sdHCB) # height at canopy base
CL<-HCB*2.0 # tree crown height
CW<-HCB*1.3 # tree crown diameter

open3d() # open a rgl window
# Plot stand
for( i in 1:Ntrees){
 LiDARForestStand(crownshape = "cone", CL = CL[i], CW = CW[i], 
             HCB = HCB[i], X = XYgrid[i,1], Y = XYgrid[i,2], dbh = 0.4, 
             crowncolor = "forestgreen", stemcolor = "chocolate4", 
             resolution="high", mesh=TRUE) 
}
                           
# Add other plot parameters
axes3d(c("x-", "x-", "y-", "z"), col="gray")       # axes
title3d(xlab = "X Coord", ylab = " Y Coord", zlab = "Height", col="red") # title
planes3d(0, 0, -1, 0.001, col="gray", alpha=0.7)   # set a terrain plane

#=======================================================================#
# EXAMPLE 03: Plotting a virtual mixed forest stand
#=======================================================================#

# 01. Plot different trees species in the stand with different crown shapes 

# Set the number of trees
Ntrees<-80 

# Set the trees locations
xcoord<-sample(1:100, Ntrees)  # x coord
ycoord<-sample(1:100, Ntrees)  # y coord

# Set a location grid of trees 
XYgrid<-cbind(xcoord,ycoord)

# Plot the location of the trees
plot(XYgrid, main="Tree location")

meanHCB<-7 # mean of the height at canopy base
sdHCB<-3   # standard deviation of height at canopy base
HCB<-rnorm(Ntrees, mean=meanHCB, sd=sdHCB) # height at canopy base
crownshape<-sample(c("cone", "ellipsoid","halfellipsoid", 
                  "paraboloid"), Ntrees, replace=TRUE) # tree crown shape 
CL<-HCB*1.3 # tree crown height
CW<-HCB     # tree crown diameter

open3d() # open a rgl window
# Plot stand

for( i in 1:Ntrees){
 LiDARForestStand(crownshape = crownshape[i], CL = CL[i], CW = CW[i], 
             HCB = HCB[i], X = as.numeric(XYgrid[i,1]), Y = as.numeric(XYgrid[i,2]), 
             dbh = 0.4, crowncolor = "forestgreen", stemcolor = "chocolate4", 
             resolution="high", mesh=TRUE)
}
                         
# Add other plot parameters
axes3d(c("x-", "x-", "y-", "z"), col="gray")       # axes
title3d(xlab = "X Coord", ylab = " Y Coord", zlab = "Height", col="red") # title
planes3d(0, 0, -1, 0.001, col="gray", alpha=0.7)   # set a terrain plane


# 02. Plot different tree height in the stand using different crown colors

# Set the number of trees
Ntrees<-80 

# Set the tree locations
xcoord<-sample(1:100, Ntrees) # x coord
ycoord<-sample(1:100, Ntrees) # y coord

# Set a location grid of trees 
XYgrid<-cbind(xcoord,ycoord)

# plot the location of the trees
plot(XYgrid, main="Tree location")

meanHCB<-7 # mean of the height at canopy base
sdHCB<-3   # standard deviation of the height at canopy base
HCB<-rnorm(Ntrees, mean=meanHCB, sd=sdHCB) # height at canopy base
crownshape<-sample(c("cone", "ellipsoid","halfellipsoid", "paraboloid"), 
                  Ntrees, replace=TRUE) # tree crown shape 
CL<-HCB*1.3 # tree crown height
CW<-HCB     # tree crown diameter

# Plot tree height based on the HCB quantiles
HCBq<-quantile(HCB) # HCB quantiles
crowncolor<-NA*(1:Ntrees) # set an empty crowncolor vector

# classify trees by HCB quantile
for (i in 1:Ntrees){
 if (HCB[i] <= HCBq[2]) {crowncolor[i]<-"red"}                        # group 1
 if (HCB[i] > HCBq[2] & HCB[i] <= HCBq[3] ) {crowncolor[i]<-"blue"}   # group 2
 if (HCB[i] > HCBq[3] & HCB[i] <= HCBq[4] ) {crowncolor[i]<-"yellow"} # group 3
 if (HCB[i] >= HCBq[4]) {crowncolor[i]<-"dark green"}                 # group 4
}
   
open3d() # open a rgl window

# Plot stand
for(i in 1:Ntrees){  
 LiDARForestStand(crownshape = crownshape[i], CL = CL[i], CW = CW[i], 
   HCB = HCB[i], X = as.numeric(XYgrid[i,1]), Y = as.numeric(XYgrid[i,2]), 
   dbh = 0.4, crowncolor = crowncolor[i],stemcolor = "chocolate4", 
   resolution="high", mesh=TRUE) 
}
   
# Add other plot parameters
axes3d(c("x-", "x-", "y-", "z"), col="gray")       # axes
title3d(xlab = "X Coord", ylab = " Y Coord", zlab = "Height", col="red") # title
planes3d(0, 0, -1, 0.001, col="gray", alpha=0.7)   # set a terrain plane

rLiDAR documentation built on Oct. 5, 2021, 9:07 a.m.