inventory <- addtreedim(inventorycheckformat(Paracou6_2016), volumeparameters = ForestZoneVolumeParametersTable) dat <- inventory[679,]
# The crown treefromthesky <- function(dat){ Crown <- dat %>% mutate(xCrown = Xutm, # X centroid yCrown = Yutm, # Y ventroid exCrown = CrownDiameter/2, eyCrown = CrownHeight/2) %>% st_as_sf(coords = c("xCrown", "yCrown")) # ellipse centroid coordinates Crown <- st_ellipse(Crown, Crown$exCrown, Crown$eyCrown) # create the ellipse }
library(ggplot2) g <- ggplot() + geom_sf(data = st_as_sf(inventory, coords = c("Xutm", "Yutm")), aes(label = ScientificName)) + geom_sf(data = Crown, fill = "forestgreen") # trees polygons plotly::ggplotly(g)
Canopy <- inventory %>% group_by(idTree) %>% # for each tree do(Crowns = # inform geometry. # Filling a column from a function whose input is a table treefromthesky(.) %>% st_as_text()) %>% # as text to easy join with a non spacial table tidyr::unnest(Crowns) # here to pass from list to character inventory <- left_join(inventory, Canopy, by = "idTree") # join spatial filtered inventory and non spatial complete inventory
#The small ones first so that they are behind the big ones on the plot inventory <- arrange(inventory, TreeHeight) ggplot() + geom_sf(data = getgeometry(inventory, Crowns), aes(alpha = TreeHeight), # label = paste(idTree, Species), fill = "forestgreen")
#The small ones first so that they are behind the big ones on the plot inventory <- arrange(inventory, TreeHeight) %>% filter(TreeHeight >30) g <- ggplot() + geom_sf(data = getgeometry(inventory, Crowns), aes(label = paste(idTree, Species), alpha = 1/2), fill = "forestgreen") # trees polygons plotly::ggplotly(g)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.