1717# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
1818# ' @param OUT_path A character with the path to the folder where the figures
1919# ' should be saved (default = current folder).
20+ # ' @param plotcolors list of three colors for plotting. Only relevant when plot
21+ # ' = TRUE. The tree points, the lowest point height and the DTM points are
22+ # ' colored by the first, second and third element of this list respectively.
2023# '
2124# ' @return A list with in the first element a numeric containing the tree height
2225# ' values for each tree point cloud. In the second element there is the list
4144# ' )
4245# ' }
4346plot_tree_height_pcs <- function (PCs_path , extension = " .txt" , dtm = NA ,
44- r = 5 , OUT_path = " ./" ) {
47+ r = 5 , OUT_path = " ./" ,
48+ plotcolors = c(" #000000" ," #08aa7c" ," #fac87f" )) {
4549 file_paths <- list.files(PCs_path ,
4650 pattern = paste(" *" , extension , sep = " " ),
4751 full.names = TRUE
@@ -55,7 +59,7 @@ plot_tree_height_pcs <- function(PCs_path, extension = ".txt", dtm = NA,
5559 for (i in 1 : length(file_names )) {
5660 print(paste(" processing " , file_names [i ]))
5761 pc <- read_tree_pc(file_paths [i ])
58- out <- tree_height_pc(pc , dtm , r , TRUE )
62+ out <- tree_height_pc(pc , dtm , r , TRUE , plotcolors )
5963 filename <- paste(OUT_path , " tree_height_" ,
6064 strsplit(file_names [i ], extension )[[1 ]], " .jpeg" ,
6165 sep = " "
@@ -97,6 +101,10 @@ plot_tree_height_pcs <- function(PCs_path, extension = ".txt", dtm = NA,
97101# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
98102# ' @param OUT_path A character with the path to the folder where the figures
99103# ' should be saved (default = current folder).
104+ # ' @param plotcolors list of three colors for plotting. Only relevant when plot
105+ # ' = TRUE. The stem points, fitted circle, the concave hull and the estimated
106+ # ' center are colored by the first, second and third and fourth element of
107+ # ' this list respectively.
100108# '
101109# ' @return A list with in the first element a numeric containing the diameter
102110# ' values for each tree point cloud, the second element the residuals on the
@@ -124,7 +132,9 @@ plot_tree_height_pcs <- function(PCs_path, extension = ".txt", dtm = NA,
124132# ' }
125133plot_circle_fit_pcs <- function (PCs_path , extension = " .txt" ,
126134 slice_height = 1.3 , slice_thickness = 0.06 ,
127- dtm = NA , r = 5 , OUT_path = " ./" ) {
135+ dtm = NA , r = 5 , OUT_path = " ./" ,
136+ plotcolors = c(" #000000" , " #1c027a" ," #08aa7c" ,
137+ " #fac87f" )) {
128138 file_paths <- list.files(PCs_path ,
129139 pattern = paste(" *" , extension , sep = " " ),
130140 full.names = TRUE
@@ -141,7 +151,7 @@ plot_circle_fit_pcs <- function(PCs_path, extension = ".txt",
141151 print(paste(" processing " , file_names [i ]))
142152 pc <- read_tree_pc(file_paths [i ])
143153 out <- diameter_slice_pc(pc , slice_height , slice_thickness , dtm = dtm ,
144- r = r , plot = TRUE )
154+ r = r , plot = TRUE , plotcolors )
145155 filename <- paste(OUT_path , " circle_" ,
146156 strsplit(file_names [i ], extension )[[1 ]], " _" ,
147157 as.character(slice_height ), " _" ,
@@ -183,6 +193,10 @@ plot_circle_fit_pcs <- function(PCs_path, extension = ".txt",
183193# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
184194# ' @param OUT_path A character with the path to the folder where the figures
185195# ' should be saved (default = current folder).
196+ # ' @param plotcolors list of three colors for plotting. Only relevant when plot
197+ # ' = TRUE. The stem points, fitted circle, the concave hull and the estimated
198+ # ' center are colored by the first, second and third and fourth element of
199+ # ' this list respectively.
186200# '
187201# ' @return A list with in the first element a numeric containing the dbh values
188202# ' for each tree point cloud, the second element the residuals on the circle
@@ -203,7 +217,9 @@ plot_circle_fit_pcs <- function(PCs_path, extension = ".txt",
203217# ' }
204218plot_dbh_fit_pcs <- function (PCs_path , extension = " .txt" , thresholdR2 = 0.001 ,
205219 slice_thickness = 0.06 , dtm = NA , r = 5 ,
206- OUT_path = " ./" ) {
220+ OUT_path = " ./" ,
221+ plotcolors = c(" #000000" , " #1c027a" ," #08aa7c" ,
222+ " #fac87f" )) {
207223 file_paths <- list.files(PCs_path ,
208224 pattern = paste(" *" , extension , sep = " " ),
209225 full.names = TRUE
@@ -221,7 +237,8 @@ plot_dbh_fit_pcs <- function(PCs_path, extension = ".txt", thresholdR2 = 0.001,
221237 pc <- read_tree_pc(file_paths [i ])
222238 out <- tryCatch(
223239 {
224- dbh_pc(pc , thresholdR2 , slice_thickness , dtm = dtm , r = r , plot = TRUE )
240+ dbh_pc(pc , thresholdR2 , slice_thickness , dtm = dtm , r = r , plot = TRUE ,
241+ plotcolors )
225242 },
226243 error = function (cond ){
227244 message(cond )
@@ -275,6 +292,10 @@ plot_dbh_fit_pcs <- function(PCs_path, extension = ".txt", thresholdR2 = 0.001,
275292# ' \code{\link{tree_height_pc}}.
276293# ' @param r Numeric value (default=5) r, parameter of
277294# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
295+ # ' @param plotcolors list of three colors for plotting. Only relevant when plot
296+ # ' = TRUE. The stem points above buttresses, stem points at breast height,
297+ # ' fitted circle, the concave hull and the estimated center are colored by the
298+ # ' first, second, third, fourth and fifth element of this list respectively.
278299# '
279300# ' @return A list with in the first element a numeric containing the dab values
280301# ' for each tree point cloud, the second element the residuals on the circle
@@ -303,7 +324,9 @@ plot_dbh_fit_pcs <- function(PCs_path, extension = ".txt", thresholdR2 = 0.001,
303324# ' }
304325plot_dab_fit_pcs <- function (PCs_path , extension = " .txt" , OUT_path = " ./" ,
305326 thresholdbuttress = 0.001 , maxbuttressheight = 7 ,
306- slice_thickness = 0.06 , dtm = NA , r = 5 ) {
327+ slice_thickness = 0.06 , dtm = NA , r = 5 ,
328+ plotcolors = c(" #000000" , " #808080" , " #1c027a" ,
329+ " #08aa7c" ," #fac87f" )) {
307330 file_paths <- list.files(PCs_path ,
308331 pattern = paste(" *" , extension , sep = " " ),
309332 full.names = TRUE
@@ -321,7 +344,7 @@ plot_dab_fit_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
321344 print(paste(" processing " , file_names [i ]))
322345 pc <- read_tree_pc(file_paths [i ])
323346 out <- dab_pc(pc , thresholdbuttress , maxbuttressheight , slice_thickness ,
324- dtm = dtm , r = r , plot = TRUE )
347+ dtm = dtm , r = r , plot = TRUE , plotcolors )
325348 filename <- paste(OUT_path , " dab_" , strsplit(file_names [i ], extension )[[1 ]],
326349 " _" , as.character(thresholdbuttress ), " _" ,
327350 as.character(maxbuttressheight ), " .jpeg" ,
@@ -385,6 +408,9 @@ plot_dab_fit_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
385408# ' \code{\link{tree_height_pc}}.
386409# ' @param r Numeric value (default=5) r, parameter of
387410# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
411+ # ' @param plotcolors list of two colors for plotting. Only relevant when plot =
412+ # ' TRUE. The crown and trunk are colored by the first and second element of
413+ # ' this list respectively.
388414# '
389415# ' @return Returns a list with the plots and individual plots saved in the
390416# ' output folder.
@@ -425,7 +451,8 @@ plot_crown_classification_pcs <- function(PCs_path, extension = ".txt",
425451 slice_thickness = 0.06 ,
426452 thresholdbuttress = 0.001 ,
427453 maxbuttressheight = 7 ,
428- dtm = NA , r = 5 ) {
454+ dtm = NA , r = 5 ,
455+ plotcolors = c(" #08aa7c" ," #fac87f" )) {
429456 file_paths <- list.files(PCs_path ,
430457 pattern = paste(" *" , extension , sep = " " ),
431458 full.names = TRUE
@@ -441,7 +468,7 @@ plot_crown_classification_pcs <- function(PCs_path, extension = ".txt",
441468 out <- classify_crown_pc(
442469 pc , thresholdbranch , minheight , buttress ,
443470 thresholdR2 , slice_thickness , thresholdbuttress ,
444- maxbuttressheight , dtm = dtm , r = r , plot = TRUE
471+ maxbuttressheight , dtm = dtm , r = r , plot = TRUE , plotcolors
445472 )
446473 filename <- paste(OUT_path , " crown_" ,
447474 strsplit(file_names [i ], extension )[[1 ]], " _" ,
@@ -515,6 +542,9 @@ plot_crown_classification_pcs <- function(PCs_path, extension = ".txt",
515542# ' \code{\link{tree_height_pc}}.
516543# ' @param r Numeric value (default=5) r, parameter of
517544# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
545+ # ' @param plotcolors list of two colors for plotting. Only relevant when plot =
546+ # ' TRUE. The stem points and the concave hull are colored by the first and
547+ # ' second element of this list respectively.
518548# '
519549# ' @return A list with in the first element a numeric containing the projected
520550# ' area values for each tree point cloud. In the second element there is the
@@ -545,7 +575,8 @@ plot_pa_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
545575 concavity = 2 , crown = FALSE , thresholdbranch = 1.5 ,
546576 minheight = 1 , buttress = FALSE , thresholdR2 = 0.001 ,
547577 slice_thickness = 0.06 , thresholdbuttress = 0.001 ,
548- maxbuttressheight = 7 , dtm = NA , r = 5 ) {
578+ maxbuttressheight = 7 , dtm = NA , r = 5 ,
579+ plotcolors = c(" #000000" ," #08aa7c" )) {
549580 file_paths <- list.files(PCs_path ,
550581 pattern = paste(" *" , extension , sep = " " ),
551582 full.names = TRUE
@@ -565,7 +596,8 @@ plot_pa_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
565596 thresholdR2 , slice_thickness ,
566597 thresholdbuttress , maxbuttressheight , dtm = dtm , r = r , FALSE
567598 )
568- out <- projected_area_pc(crown_pc $ crownpoints , concavity , TRUE )
599+ out <- projected_area_pc(crown_pc $ crownpoints , concavity , TRUE ,
600+ plotcolors )
569601 plot_area <- out $ plot +
570602 ggplot2 :: ggtitle(bquote(PCA == .(round(out $ pa , 2 )) ~ m ^ 2 ))
571603 filename <- paste(OUT_path , " pca_" , strsplit(
@@ -576,7 +608,7 @@ plot_pa_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
576608 sep = " "
577609 )
578610 } else {
579- out <- projected_area_pc(pc , concavity , TRUE )
611+ out <- projected_area_pc(pc , concavity , TRUE , plotcolors )
580612 plot_area <- out $ plot
581613 filename <- paste(OUT_path , " pa_" ,
582614 strsplit(file_names [i ], extension )[[1 ]], " _" , as.character(concavity ),
@@ -648,6 +680,7 @@ plot_pa_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
648680# ' \code{\link{tree_height_pc}}.
649681# ' @param r Numeric value (default=5) r, parameter of
650682# ' \code{\link{tree_height_pc}}. Only relevant if a dtm is provided.
683+ # ' @param plotcolor color for plotting 3D shape. Only relevant when plot = TRUE.
651684# '
652685# ' @return a numeric containing the volume values for each tree point cloud.
653686# ' Figures are saved in the output folder.
@@ -677,7 +710,8 @@ plot_av_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
677710 alpha = 1 , crown = FALSE , thresholdbranch = 1.5 ,
678711 minheight = 1 , buttress = FALSE , thresholdR2 = 0.001 ,
679712 slice_thickness = 0.06 , thresholdbuttress = 0.001 ,
680- maxbuttressheight = 7 , dtm = NA , r = 5 ) {
713+ maxbuttressheight = 7 , dtm = NA , r = 5 ,
714+ plotcolor = " #fac87f" ) {
681715 file_paths <- list.files(PCs_path ,
682716 pattern = paste(" *" , extension , sep = " " ),
683717 full.names = TRUE
@@ -703,7 +737,7 @@ plot_av_pcs <- function(PCs_path, extension = ".txt", OUT_path = "./",
703737 sep = " "
704738 )
705739 } else {
706- out <- alpha_volume_pc(pc , alpha , TRUE )
740+ out <- alpha_volume_pc(pc , alpha , TRUE , plotcolor )
707741 fig_name <- paste(OUT_path , " av_" ,
708742 strsplit(file_names [i ], extension )[[1 ]], " _" , as.character(alpha ),
709743 " .png" ,
0 commit comments