inventory speciescriteria type fuel objective diversification specieslax objectivelax advancedloggingparameters = loggingparameters() multilignes "MainTrail"
harvestable, selected, futurereserve
inventory = addtreedim(inventorycheckformat(Paracou6_2016), volumeparameters = ForestZoneVolumeParametersTable)) #3539 rows (Paracou: 3620 rows) speciescriteria = SpeciesCriteria scenario = "manual" fuel = "0" objective = 20 diversification = TRUE specieslax = FALSE objectivelax = FALSE advancedloggingparameters = loggingparameters() # MainTrail
# inventory <- inventory %>% # filter(DeathCause = NULL) %>% # select only still alived trees (after MainTrails) NULL ou NA # mutate(VisibleDefectProba = advancedloggingparameters$VisiblyRottenModel(DBH)) %>% # mutate(VisibleDefect = sample(c(0,1), size = 1, replace = F, prob = VisibleDefectProba)) # 1 = default tree, 0 = no visible default (là ma fct ne sait pas qd elle doit mettre 0 ou 1) # filter(VisibleDefect = "0") %>% if (fuel =="2"){ VO = objective * unique(inventory$PlotArea) }else{ VO = (objective + (objective *((advancedloggingparameters$ObjectiveBonus)/100)) ) * unique(inventory$PlotArea) # to compensate for the designated hollow wood. } (20 + (20*0.3)) *6.25 (20*6.25) + ((20*6.25)*0.3) #same
speciescriteria = SpeciesCriteria genuscriteria <- speciescriteria %>% # for economic names that relate to entire genus filter(Species == "spp") speciescriteria <- speciescriteria %>% filter(Species != "spp") inventoryA <- inventory %>% left_join(genuscriteria, by = "Genus", suffix = c("", ".genus")) %>% select(-Species.genus) %>% left_join(speciescriteria, by = c("Genus","Species"), suffix = c(".genus", ".species")) %>% dplyr::rename(VernName = VernName.genus) %>% mutate(ONFName = ifelse(is.na(VernName.species), VernName.genus.genus, VernName.species)) %>% select(-VernName.species, -VernName.genus.genus) %>% mutate(Commercial = ifelse(is.na(Commercial.species), Commercial.genus, Commercial.species)) %>% mutate(MinFD = ifelse(is.na(MinFD.species), MinFD.genus, MinFD.species)) %>% mutate(UpMinFD = ifelse(is.na(UpMinFD.species), UpMinFD.genus, UpMinFD.species)) %>% mutate(MaxFD = ifelse(is.na(MaxFD.species), MaxFD.genus, MaxFD.species)) %>% select(-Commercial.species, -Commercial.genus, -MinFD.species, -MinFD.genus, -UpMinFD.species, -UpMinFD.genus, -MaxFD.species, -MaxFD.genus) ConcernedRows <- which(inventoryA$ONFName == "maho rouge" & (inventoryA$ScientificName == "Lecythis_poiteaui"| inventoryA$ScientificName == "Lecythis_praeclara" | inventoryA$ScientificName == "Lecythis_holcogyne" | inventoryA$ScientificName == "Lecythis_pneumatophora"| inventoryA$ScientificName == "Lecythis chartacea"| inventoryA$ScientificName == "Lecythis zabucajo")) if(length(ConcernedRows) > 0){ inventoryA$ONFName[ConcernedRows] <- NA inventoryA$Commercial[ConcernedRows] <- NA inventoryA$MinFD[ConcernedRows] <- NA inventoryA$UpMinFD[ConcernedRows] <- NA inventoryA$MaxFD[ConcernedRows] <- NA } ConcernedRows <- which(inventoryA$ONFName == "balata blanc" & (inventoryA$ScientificName == "Micropholis_melinoniana"| inventoryA$ScientificName == "Micropholis_egensis" | inventoryA$ScientificName == "Micropholis_cayennensis" | inventoryA$ScientificName == "Micropholis_obscura")) if(length(ConcernedRows) > 0){ inventoryA$ONFName[ConcernedRows] <- NA inventoryA$Commercial[ConcernedRows] <- NA inventoryA$MinFD[ConcernedRows] <- NA inventoryA$UpMinFD[ConcernedRows] <- NA inventoryA$MaxFD[ConcernedRows] <- NA } ConcernedRows <- which(inventoryA$ONFName == "kimboto" & (inventoryA$ScientificName == "Pradosia_cochlearia"| inventoryA$ScientificName == "Pradosia_huberi")) if(length(ConcernedRows) > 0){ inventoryA$ONFName[ConcernedRows] <- NA inventoryA$Commercial[ConcernedRows] <- NA inventoryA$MinFD[ConcernedRows] <- NA inventoryA$UpMinFD[ConcernedRows] <- NA inventoryA$MaxFD[ConcernedRows] <- NA } filter(inventoryA, ScientificName == "Micropholis_obscura") # Special cases: # Maho rouge = tous les Lecythis (sauf Lecythis poiteaui, Lecythis praeclara et Lecythis holcogyne , Lecythis pneumatophora et Lecythis chartacea, Lecythis zabucajo) # Balata blanc = Tous les Micropholis (sauf Micropholis melinoniana, Micropholis egensis, Micropholis cayennensis et M. obscura) # Kimboto = tous les Pradosia sauf Pradosia cochlearia et P. huberi # cèdre blanc = Ocotea guianensis, O. canaliculata, O. oblonga et O. argyrophylla. # cèdre noir = Ocotea tomentella, Ocotea schomburgkiana, O. glomerata et O. ceanothifolia. # Dodomissinga = Parkia decussata, P. gigantocarpa, P. nitida, P. reticulata, P. ulei et P. velutina. # Cèdre gris = les Lauraceae qui ne sont pas d'autres cèdres ...
# To control dupli <- inventoryA[duplicated(inventoryA$idTree), ] # les lignes dupliquées sont dues aux genres qui concernent plsrs essences NAtable <- inventoryA[is.na(inventoryA$Commercial),] #2151 ind not linked NAtablescfc <- as.data.frame(unique(inventoryA[is.na(inventoryA$Commercial),]$ScientificName)) #270 sp not linked NAtablevern <- as.data.frame(unique(inventoryA[is.na(inventoryA$Commercial),]$VernName)) #126 sp not linked NAtablevern <- unique(NAtable$VernName) #126 NAtablescfc <- unique(NAtable$ScientificName) #270 filter(inventoryA, Commercial =="1") #177 ind filter(inventoryA, Commercial =="2") #1211 ind comerc <- filter(inventoryA, Commercial =="1"| Commercial =="2")#1388 all(comerc$CommercialSp == TRUE)#FALSE
# Il manque les scénarios dans les conditions -_- #select essences HarverstableConditions <- # = 1 boolean vector if (diversification || (!diversification && specieslax)) { inventoryA$Commercial =="1"| inventoryA$Commercial == "2" # now or maybe after we will diversify } else if (!diversification && !specieslax) { Commercial == "1" # We will never diversify } #select diameters HarverstableConditions <- HarverstableConditions & (inventoryA$DBH >= inventoryA$MinFD & inventoryA$DBH <= inventoryA$MaxFD) # harvestable species, accord by their DBH #select spatially # HarverstableConditions <- HarverstableConditions & () ##slope ##isolement ##MainTrails out inventoryB <- inventoryA %>% mutate(Commercial = ifelse(is.na(Commercial), "0", Commercial)) %>% #To avoid NA problems mutate(LoggingStatus = ifelse(HarverstableConditions, #Under the above criteria, designate the harvestable species "harvestable", "non-harvestable")) %>% mutate(LoggingStatus = ifelse(Commercial == "0", #The non-commercial species are non-harvestable. "non-harvestable", LoggingStatus)) %>% mutate(LoggingStatus = ifelse( !diversification & specieslax & #designate the secondarily harvestable species, because diversification only if necessary LoggingStatus == "harvestable" & Commercial == "2", "harvestable2nd", LoggingStatus)) HarvestableTable <- inventoryB %>% filter(LoggingStatus == "harvestable") #96 ind HVinit <- sum(HarvestableTable$TreeHarvestableVolume) #compute the harvestable volume in the plot for these criteria #all the inventory: HVinit = 2088.052 m3 #just harvestable: HVinit = 365.3774 m3
# if objective achieved at the first attempt inventoryC <- inventoryB %>% mutate(Selected = ifelse(HVinit == VO & LoggingStatus == "harvestable", "1", NA))# if we have our volume, harvestable sp = selected sp inventoryC <- add_column(inventoryC, Up = 0) # Create a column to indicate Which sp is FD uped. Or create this column d'office in speciescriteria. "0" = no uped, "1"= uped. dans speciescriteria ou inventory ? if (HVinit < VO){ #diversification is necessary, designate the secondary-economic-rank species too if (!diversification && specieslax){ inventoryD <- inventoryC %>% mutate(Condition = ifelse(LoggingStatus == "harvestable2nd" | LoggingStatus == "harvestable", TRUE, FALSE)) %>% group_by(Condition) %>% arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% mutate(Selected = ifelse(Condition & VolumeCumSum <= VO, "1", NA)) %>% select(-Condition) HarvestableTable <- inventoryD %>% filter(Selected == "1") HVlax <- sum(HarvestableTable$TreeHarvestableVolume) #49.69643 Harvestable volume, with specieslax permission if (HVlax < VO && objectivelax) message("The exploitable volume (= ",paste(HVlax),") is still lower (by ",paste(VO- HVlax),") than your objective volume despite the diversification you have allowed (without the diversification HVinit= ",paste(HVinit),"). In this case, you have chosen to continue harvesting with a volume lower than your objective.") if (HVlax < VO && !objectivelax) stop("The harvestable volume = ",paste(HVlax),") is still lower (by ",paste(VO- HVlax),") than your objective volume despite the diversification you have allowed (without the diversification HVinit= ",paste(HVinit),"). By default or by your choice, the simulation stops. If you wish to continue the exploitation in spite of an exploitable volume lower than your objective volume, you have the argument 'objectivelax'.") if (!HVlax == VO) message("The harvestable volume (=",paste(HVinit),") was lower (by ",paste(VO- HVinit),") than your objective volume. You have chosen to diversify your species selection in this case. The exploitation was therefore carried out on this diversified selection of species.") } if (!diversification && !specieslax && objectivelax) message("The harvestable volume (=",paste(HVinit),") is less (by ",paste(VO- HVinit),") than your objective volume. In this case you have chosen to continue logging without diversifying your species.") if (diversification && objectivelax) message("The harvestable volume (=",paste(HVinit),") is less (by ",paste(VO- HVinit),") than your objective volume. In this case you have chosen to continue logging.") if ((!specieslax & !objectivelax) | (diversification && !objectivelax)) stop("The harvestable volume (=",paste(HVinit),") is lower (by ",paste(VO- HVinit),") than your objective volume. By default or by your choice, the simulation stops. If you wish to continue the exploitation in spite of a harvestable volume lower than your objective volume, you can use the argument 'objectivelax' or the diversification of species (if it is not already the case).") } if (HVinit > VO) { inventoryD <- inventoryC %>% mutate(LoggingStatus = ifelse( Commercial == "1" & (DBH >= UpMinFD & DBH <= MaxFD), #designate preferred individuals of first economic rank species, when the plot is species-rich. "harvestableUp", LoggingStatus)) %>% mutate(Up = ifelse(Commercial == "1", "1", Up))# to inform that the "1" ranks have been FD upgraded. Pas mieux de le faire à l'sp? # test "Commercial"= "1" pour les "harvestableUp" if (!diversification) { HarvestableTable <- inventoryD %>% filter(LoggingStatus == "harvestableUp") HVupCommercial1 <- sum(HarvestableTable$TreeHarvestableVolume) #82.42823. compute the harvestable volume with upgraded FD individuals if (HVupCommercial1 == VO){ inventoryE <- inventoryD %>% mutate(Selected = ifelse(HVupCommercial1 == VO & LoggingStatus == "harvestableUp", "1", NA))# if harvestableUp individuals are sufficient to have our volume, harvestableUp ind = selected ind message("As the harvestable volume (=",paste(HVinit),") was higher (by ",paste(VO- HVinit),") than the objective volume, the Minimum Falling Diameter (MinFD) of 1st economic rank species were increased. The objective volume has now been reached.") } if (HVupCommercial1 > VO){ # only individuals with DBH > FD are taken, but not all because their volumes > VO inventoryE<- inventoryD %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp", TRUE, FALSE)) %>% group_by(Condition) %>% arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% mutate(Selected = ifelse(Condition & VolumeCumSum <= VO, "1", NA)) %>% select(-Condition) HarvestableTable <- inventoryE %>% filter(Selected == "1") HVupCommercial1adjust <- sum(HarvestableTable$TreeHarvestableVolume) #49.69643 Harvestable volume, with "1" rank species and upgraded FD individuals only message("The harvestable volume (=",paste(HVupCommercial1),") is always higher (by ",paste(VO- HVupCommercial1),") than your objective volume despite the increase in Minimum Falling Diameter (MinFD) (Initial harvestable volume = HVinit). In order to reach your objective volume, the trees were selected in decreasing order of volume until the objective volume was reached.") } if (HVupCommercial1 < VO){ inventoryE<- inventoryD %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp" | LoggingStatus == "harvestable", TRUE, FALSE)) %>% group_by(Condition) %>% arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% mutate(Selected = ifelse(Condition & VolumeCumSum <= VO, "1", NA)) %>% select(-Condition) HarvestableTable <- inventoryE %>% filter(Selected == "1") HVupCommercial1adjust <- sum(HarvestableTable$TreeHarvestableVolume) #49.69643 Harvestable volume, with "1" rank species and upgraded FD individuals message("As the harvestable volume (=",paste(HVinit),") was higher (by ",paste(VO- HVinit),") than the objective volume, the Minimum Falling Diameter (MinFD) of the 1st economic rank species were increased with retention of some stems with DBH lower than the UpMinFD to ensure that the objective volume was attained.") } } if (diversification) { HarvestableTable <- inventoryD %>% filter(LoggingStatus == "harvestableUp" | LoggingStatus == "harvestable") #the upgraded 1st rank and normal 2nd rank. HVupCommercial1 <- sum(HarvestableTable$TreeHarvestableVolume) #173.334 m3 if (HVupCommercial1 == VO){ inventoryE <- inventoryD %>% mutate(Selected = ifelse(LoggingStatus == "harvestableUp" | LoggingStatus == "harvestable", "1", NA))# if we have our volume, harvestable ind = selected ind message("As the harvestable volume (=",paste(HVinit),") was higher (by ",paste(VO- HVinit),") than the objective volume, the Minimum Falling Diameter (MinFD) of the 1st economic rank species were increased. The objective volume has now been reached. It was not necessary to increase the MinFD of the other economic species") } if (HVupCommercial1 < VO){ inventoryE<- inventoryD %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp" | LoggingStatus == "harvestable", TRUE, FALSE)) %>% group_by(Condition) %>% arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% mutate(Selected = ifelse(Condition & VolumeCumSum <= VO, "1", NA)) %>% select(-Condition) HarvestableTable <- inventoryE %>% filter(Selected == "1") HVupCommercial1adjust <- sum(HarvestableTable$TreeHarvestableVolume) #49.69643 Harvestable volume, with "1" rank species and upgraded FD individuals, and 2nd rank no upgraded FD individuals message("As the harvestable volume (=",paste(HVinit),") was higher (by ",paste(VO- HVinit),") than the objective volume, the Minimum Falling Diameter (MinFD) of the 1st economic rank species were increased with retention of some stems with DBH lower than the UpMinFD to ensure that the objective volume was attained. It was not necessary to raise the MinFDs of other economic species.") } if (HVupCommercial1 > VO){ inventoryE <- inventoryD %>% mutate(LoggingStatus = ifelse(LoggingStatus == "harvestable" & Commercial == "2" & DBH >= UpMinFD, #designate preferred individuals of 2nd economic rank species too, when the plot is species-rich. "harvestableUp", LoggingStatus)) %>% mutate(Up = ifelse(Commercial == "2", "1", Up))# to inform that the "2" ranks have been FD upgraded. Pas mieux de le faire à l'sp? HarvestableTable <- inventoryE %>% filter(LoggingStatus == "harvestableUp") HVupCommercial12 <- sum(HarvestableTable$TreeHarvestableVolume) #271.2342 Harvestable volume, with upgraded FD individuals if (HVupCommercial12 == VO){ inventoryF <- inventoryE %>% mutate(Selected = ifelse(LoggingStatus == "harvestableUp", "1", NA))# if we have our volume, harvestable ind = selected ind } if (HVupCommercial12 != VO){ inventoryF <- inventoryE %>% mutate(Condition = ifelse(LoggingStatus == "harvestableUp" | LoggingStatus == "harvestable", TRUE, FALSE)) %>% group_by(Condition) %>% arrange(desc(TreeHarvestableVolume)) %>% mutate(VolumeCumSum = cumsum(TreeHarvestableVolume)) %>% ungroup() %>% mutate(Selected = ifelse(Condition & VolumeCumSum <= VO, "1", NA)) %>% select(-Condition) HarvestableTable <- inventoryF %>% filter(Selected == "1") HVupCommercial12adjust <- sum(HarvestableTable$TreeHarvestableVolume) #45.44885 Harvestable volume, with upgraded FD individuals } message("As the harvestable volume (=",paste(HVinit),") was higher (by ",paste(VO- HVinit),") than the objective volume, it was necessary to increase the Minimum Falling Diameter (MinFD) of all species. The objective volume has now been reached.") } } } # Apply S. Schmitt's "Rotten" predictive model to identify "truly" hollow designated trees. inventoryG <- inventoryF %>% mutate(ProbedHollowProba = ifelse(Selected == "1", advancedloggingparameters$RottenModel(DBH), NULL)) %>% #Estimates the probability of being probed hollow # generate either "1" or "0" randomly for each line, depending on the proba associated with the line: rowwise() %>% mutate(ProbedHollow = ifelse(!is.na(ProbedHollowProba), sample(c(1,0), size = 1, replace = F, prob = c(ProbedHollowProba, 1-ProbedHollowProba)), NA)) %>% # 1 = hollow tree, 0 = not hollow mutate(ProbedHollow = factor(as.numeric(ProbedHollow))) %>% mutate(Selected = ifelse(ProbedHollow == "1", "0", Selected)) %>% #hollow probed trees are deselected #non-upgraded MinFD species: mutate(Up = ifelse(is.na(Up) , "0", Up)) if (scenario != "RIL3fuelhollow"| (scenario == "manual"& fuel !="2")) HarvestableTable <- inventoryG %>% filter(Selected == "1") VolumewithHollowslost <- sum(HarvestableTable$TreeHarvestableVolume) #128.5047. Harvestable volume, with Hollows lost VO - VolumewithHollowslost #34 m3 lost: the bonus is therefore generous here (37.5 m3 of bonus). if (scenario == "RIL3fuelhollow"| (scenario == "manual"& fuel =="2")) { # Hollow trees = fuel wood: inventoryH <- inventoryG %>% mutate(DeathCause = ifelse(ProbedHollow == "1", "hollowfuel", NA)) # remplacer NA par DeathCause dans le simulateur ONF # Create 2 points vectors with coordinates of the probed hollow trees: "HollowTreesPoints" and "EnergywoodTreesPoints": HollowTreescoord <- selecInventory %>% filter(ProbedHollow == "1") sp::coordinates(HollowTreescoord) <- ~ Xutm + Yutm # transformer l'inventaire en objet spatialisé en en informant les coordonnées sp::proj4string(HollowTreescoord) <- raster::crs(topography) # attribuer le crs de Paracou à notre inventaire spatialisé HollowTreescoord <- st_as_sf(HollowTreescoord) %>% select(geometry) HollowTreesPoints <- HollowTreescoord$geometry %>% st_cast("MULTIPOINT") # HollowTreesPoints <- st_multipoint(x = HollowTreescoord$geometry) EnergywoodTreesPoints <- HollowTreesPoints }
#Future: select essence and diameters inventoryH <- inventoryG %>% mutate(LoggingStatus = ifelse(Commercial == "1" & (DBH >= advancedloggingparameters$FutureTreesMinDiameter & DBH < MinFD), "future", LoggingStatus)) #Reserve # Randomly select the reserved trees (among the futures, as many as the number of trees exploited): StemNbr <- sum(as.numeric(inventoryH$Selected == "1"), na.rm = TRUE)#29 selected ind ReserveRows <- sample(which(inventoryH$LoggingStatus == "future"), size = StemNbr, replace = F) inventoryH$LoggingStatus[ReserveRows] <-"reserve"
# Créer un vecteur ("HarvestableTreesPoints") de points de coordonnées des arbres LoggingStatus = "harvestable" ou "harvestableUp" ou "harvestable2nd". HarvestableTreesPoints <- inventory %>% filter(LoggingStatus == "harvestable" | LoggingStatus == "harvestableUp" | LoggingStatus == "harvestable2nd") if (dim(HarvestableTreesPoints)[1] != 0) { sp::coordinates(HarvestableTreesPoints) <- ~ Xutm + Yutm sp::proj4string(HarvestableTreesPoints) <- raster::crs(topography) HarvestableTreesPoints <- st_as_sf(as(HarvestableTreesPoints,"SpatialPoints")) } HarvestableTreesPoints <- HarvestableTreesPoints$geometry %>% st_cast("MULTIPOINT") HarvestableTreesPoints <- st_multipoint(x = as.matrix(HarvestableTreescoord)) # Créer un vecteur ("SelectedTreesPoints") de points de coordonnées des arbres Selected = 1. SelectedTreescoord <- inventory %>% filter(Selected == "1") %>% select(Xutm, Yutm) SelectedTreesPoints <- st_multipoint(x = as.matrix(SelectedTreescoord)) # Créer un vecteur ("FutureTreesPoints") de points de coordonnées des arbres LoggingStatus = "future" FutureTreescoord <- inventory %>% filter(LoggingStatus == "future") %>% select(Xutm, Yutm) FutureTreesPoints <- st_multipoint(x = as.matrix(FutureTreescoord)) # Créer un vecteur ("ReserveTreesPoints") de points de coordonnées des arbres LoggingStatus = "reserve". ReserveTreescoord <- inventory %>% filter(LoggingStatus == "reserve") %>% select(Xutm, Yutm) ReserveTreesPoints <- st_multipoint(x = as.matrix(ReserveTreescoord)) #where specieslax was not necessary, consider eco2s as non-exploitable: inventoryI <- inventoryH %>% mutate(LoggingStatus = ifelse(HVinit > VO & LoggingStatus == "harvestable2nd", "non-harvestable", LoggingStatus)) unique(inventoryI$LoggingStatus) write.csv2(inventoryI, "D:/VSC Kourou/DATA/PostDesignationInventory.csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.