Exercices
Authors: Clément Hardy1
Affiliations: 1Université du Québec en Outaouais (UQO)\
Thinking about what you can do with Magic Harvest¶
The three exercices that I propose here will not ask you to code in any programming langage.
What I’m going to do is ask you to write step-by-step algorithms in plain english about what a possible script used with Magic Harvest (whatever the programming langage you choose down the road) will be used for different use case.
In that way, when you’ll try to use Magic Harvest for your own research, I hope that you’ll have a general idea of what you’ll want to do with it. The implementation of your algorithm in a programming - the coding part - is not necesseraly the most complex thing to do, especially with the new AI tools that are accessible today.
Example of an algorithm in plain english¶
Here is an example of the kind of algorithm I propose that you’ll write in the following exercises, in plain english.
Here, we’ll simply write the algorithm for a script that will do the following :
We want to do repeated partial cutting every 30 years for 90 years, and simple clearcutting in a landscape : So here, what we want to do is to harvest a certain percentage of the target with partial cutting, which demands that when we select a stand for harvesting with partial cutting, we have to come back every 30 years to harvest it until we reach 90 years, and then we stop coming back.
Here is the resulting algorithm in plain english to write a script that will do this with Magic Harvest :
- Read the state of the landscape and put it in variables
- Define or read target of hectares to harvest with partial cutting and clear cutting
- Read a file containing information about stands that have been registered with repeated partial cutting and put it in a variable
- For each stand registered for repeated partial cutting :
- Check if this year should be a year where the given stand is harvested with partial cutting (period of 30 years)
- If it is the case, write the code corresponding to partial cutting in the management map for all of the pixels of the stand, and then record the - next time that the stand should be harvested in the variable
- If not, do nothing.
- Check if the stand has reached its last partial cutting (90 years are done)
- If so, remove the stand from the variable
- Check if this year should be a year where the given stand is harvested with partial cutting (period of 30 years)
- Check if we need to add new stands to list of regular partial cutting reach the % of hectare harvested each year with partial cutting
- If that’s the case, rank the stands in the landscape based on their biomass.
- Then, select stands starting with those with a lot of biomass until we reach the target. Add each of these stands to the list of repeated partial- cutting.
- Then, look at all of the stands in the landscape and rank them by biomass
- For each stand, looking at those with the most biomass first, register them for harvesting with clearcutting in the management map for all of the- pixels of the stand
- Stop when we have reached the target of hectares to harvest with clearcutting
- Export the management map and edit the parameter files of B. Harvest.
First exercise - Salvage logging¶
Solution to Exercise 1 #
Here is the resulting algorithm in plain english to write a script that will do this with Magic Harvest.
The solution here is relatively simple, because we’re letting Biomass Harvest take a lot of decisions.
Read latest fire map
Edit the management area map to create a new one on the disturbance
Edit the biomass harvest parameter file to make sure it will read the new map and edit its implementation table to add a new line to harvest 70% of the stands or of the surface of the new management area
Second exercise - Clearcutting, Partial cutting and protected areas¶
Solution to Exercise 2 #
- Read the position of the stands and their composition in terms of vegetation/age cohorts and their biomass
- Read the location of protected areas, and create an object that defines if a stand is in a protected area or not
- Read or define in the script how clearcutting and partial cutting are done so that we can estimate the biomass harvested when we apply it to a - stand
- Prepare an empty management map filled with zeroes
- Define the overall biomass target
- Harvest 70% with clearcutting :
- Rank the stand in the landscape based on their biomass
- Create a list of stands harvested with clearcutting
- Add stands to the clearcutting list one by one in ranking order
- Check everytime if a stand is in a protected area. If it is not, then do not add it to the list
- Estimate the biomass that will be harvested with the clearcutting in each given stand, and compute a sum
- When the sum reaches 70% of the biomass target, stop the loop.
- Harvest 30% with partial cutting :
- Same thing as with clearcutting : Rank stands according to biomass, add them to the list if they are not in a protected area or already - - - harvested by clearcutting. Compute the biomass that will be harvested by partial cutting everytime we add a stand to the list, and compute the - sum. When sum reaches 30% of the biomass target, stop the loop.
- For both the clearcutting and partial cutting list, look at each stand in both list
- For each pixels of the stand, write the code corresponding to either clearcutting or partial cutting in the pixels of the management map
- Export the management map as a raster map
- Edit the biomass harvest parameter file to make sure it will read the new management map as both its management area raster and stand raster, and edit its implementation table to add two new lines to harvest 100% of the pixels corresponding to the code of clearcutting and partial - cutting with the respective prescription.
Third exercise - Clearcutting and complex planting of rare species¶
Solution to Exercise 3 #
- Read the position of the stands and their composition in terms of vegetation/age cohorts and their biomass
- Read the location of protected areas, and create an object that defines if a stand is in a protected area or not
- Read or define in the script how clearcutting is done so that we can estimate the biomass harvested when we apply it to a stand
- Prepare an empty management map filled with zeroes
- Prepare an object to record new clearcutting prescription with different types of planting following the clearcut.
- Define the overall biomass target
- Select the stands to harvest :
- Rank all of the stands in the landscape according to their biomass.
- We add the stands one by one in their ranking order to the list of stands harvested with clearcutting for the timestep.
- For each stand, we compute the biomass that clearcutting will harvest and we compute the sum.
- We stop when we have reached the biomass target.
- We select 20% of stands randomly in the list of stand harvested with clearcutting.
- For the 80% not selected, we input the code for simple clearcutting (without planting) in the empty management map.
- For the 20% selected for planting, we look at stands one by one.
- We select the 2 species to plant by looking at the composition of the stand and our priority list for planting.
- Once the 2 species are selected, we check if clearcutting prescription with a planting of one of these 2 species already exist in our object to - record new planting prescriptions.
- If it exist, we simply get the code for the two prescriptions that will plant these two species.
- If it doesn’t exist, we create them and generate new codes for them.
- We then distribute the codes for the 2 planting prescriptions randomly in the cells of the stand in the management map, trying to have a 50/50 - ratio between the number of pixels with the first planting prescription and the second.
- Export the management map as a raster map
- Edit the biomass harvest parameter file to make sure it will read the new management map as both its management area raster and stand raster, - and edit its implementation table to add two new lines to harvest 100% of the pixels corresponding to the code of clearcutting and partial cutting with the respective prescription.
- Hardy, C., Messier, C., Boulanger, Y., Cyr, D., & Filotas, É. (2025). Climate is stronger than you think: Exploring functional planting and TRIAD zoning for increased forest resilience to extreme disturbances. PLOS One, 20(6), e0326627. 10.1371/journal.pone.0326627