Volumetrics
Warning
This library is under development, none of the presented solutions are available for download.
Process forest inventory data. Adjust volumetric equations and taper functions for later use.
Class Parameters
Volumetrics(df, tree_identifier, tree_height, tree_dbh, tree_bark,
segment_height, segment_diameter, tree_bark)
Parameters | Description |
---|---|
df | The dataframe containing the cubage data. |
tree_identifier | The name of the column that contains the unique identifiers of the trees. |
tree_height | The name of the column that contains the total heights of the trees (meters). |
tree_dbh | The name of the column containing the diameter at breast height (DBH) values of the trees (centimeters). |
tree_bark | (Optional) The name of the column containing the bark thickness values of the trees (centimeters). If tree_bark == None return only volumes with bark on 'get_volumes()' method. |
segment_height | (Optional) The name of the column containing the heights of the cubed segments of the trees (meters). Required for fit_taper_functions() method. |
segment_diameter | (Optional) The name of the column containing the diameters of the cubed segments of the trees (centimeters). Required for fit_taper_functions() method. |
tree_bark | (Optional) The name of the column containing tree bark (centimeters). |
Class Functions
Volumetrics.get_volumes()
Volumetrics.fit_taper_functions(models,iterator) #(1)
Volumetrics.fit_volumetric_functions(models, iterator, vol_column) #(2)
Volumetrics.get_individual_diameter(hi,tree_height, tree_dbh) #(3)
Volumetrics.get_individual_taper_volume(tree_height, tree_dbh, stump=0.1) #(4)
Volumetrics.get_individual_volume(tree_height, tree_dbh) #(5)
- models = (Optional) List of models to be fitted! If
models == None
uses all available models.
iterator = (Optional) A column name string. Defines wich column will be used as a iterator. Could be a farm name, plot name, code or any unique identification tag. - models = (Optional) List of models to be fitted! If
models == None
uses all available models.
iterator = (Optional) A column name string. Defines wich column will be used as a iterator. Could be a farm name, plot name, code or any unique identification tag.
vol_column = (Optional) A column name to the volume values. Ifvol_column == None
, it uses de volumes obtained by theget_volumes()
method to fit the volumetric functions. - hi = Fraction of height from which you want to obtain the diameter (meters).
tree_height = Total height of the tree (meters).
tree_dbh = Diameter at breast height (DBH) value of the tree (centimeters). - tree_height = Total height of the tree (meters).
tree_dbh = Diameter at breast height (DBH) of the tree (centimeters).
stump = Stump height (meters). By default, usesstump = 0.1
. - tree_height = Total height of the tree (meters).
tree_dbh = Diameter at breast height (DBH) of the tree (centimeters).
Parameters | Description |
---|---|
.get_volumes() | Returns the volume of each cubed segment and the total volume of each tree separated by tree_identifier . If tree_bark == None , it returns only the volume with bark; otherwise, it returns the volume with and without bark. |
.fit_taper_functions() | Fits the available taper function models. Saves a .json file with the coefficients for each fitted model and a .pkl file for the fitted ANN's. |
.get_individual_diameter() | Returns a pandas dataframe with diameter at a given hi height of the tree for each fitted taper model. |
.get_individual_taper_volume() | Returns a pandas DataFrame with the estimated volume for the provided height and diameter at breast height for each fitted taper function. It uses the integration of taper functions to obtain the result. |
.get_individual_volume() | Returns a pandas DataFrame with the estimated volume for the provided height and diameter at breast height for each fitted volumetric function. |
Example Usage
taper_functions_example.py | |
---|---|
1 2 |
|
- Import
Volumetrics
class. - Import
pandas
for data manipulation.
Create a variable for the Volumetrics Class
taper_functions_example.py | |
---|---|
3 4 5 6 7 8 9 |
|
- Load your csv file.
- Create the variable
vol
containing theVolumetrics
class. - Calculate volumes for each tree and segments em save the results on
calculated_volumes_df
variable. - Fit the taper functions and save the performance metris in
metrics
variable. It will create a.json
file with the models coefficients and a.pkl
files for the fitted ann models. - Get the diameter at 1.3 meters of a tree with a total height of 25 meters and a diameter at breast height (DBH) of 30 centimeters.
- Obtains the volumes calculated from the integration of taper functions for a tree with a height of 30 meters, a diameter at breast height of 22.8 centimeters, considering a stump height of 0.15 meters
- Obtains the volumes calculated from the fitted volumetric functions for a tree with a height of 30 meters and a diameter at breast height of 22.8 centimeters.
Available taper models
Notation
- \( β_n \): Fitted parameters
- \( d_i \): Diameter (cm)
- \( \text{dbh} \): Diameter at breast height (cm)
- \( H \): Total height (m)
- \( h_i \): Segment height (m)
Artificial Neural Network
When selecting the 'ann' model, 5 different structures of artificial neural networks will be tested. Only the result from 1 model will be returned. The model returned will be selected by the ranking function.
For the 'ann' model, the module sklearn.neural_network.MLPRegressor is used.
Available volumetric models
Use the same ann models used for taper function.
Notation
- \( V \): Estimated volume (m³)
- \( \text{dbh} \): Diameter at breast height (cm)
- \( H \): Total height (m)
Ranking function
To select the best-performing models and rank them accordingly, the following metrics are obtained:
Métric name | Structure |
---|---|
Mean Absolute Error (MAE) | \( MAE = \frac{1}{n} \sum_{i=1}^{n} \|y_i - \hat{y}_i\| \) |
Mean Absolute Percentage Error (MAPE) | \( MAPE = \frac{100}{n} \sum_{i=1}^{n} \left\|\frac{y_i - \hat{y}_i}{y_i}\right\| \) |
Mean Squared Error (MSE) | \( MSE = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2 \) |
Root Mean Squared Error (RMSE) | \( RMSE = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2} \) |
R Squared (Coefficient of Determination) | \( R^2 = 1 - \frac{\sum_{i=1}^{n} (y_i - \hat{y}_i)^2}{\sum_{i=1}^{n} (y_i - \bar{y})^2} \) |
Explained Variance (EV) | \( EV = 1 - \frac{Var(y - \hat{y})}{Var(y)} \) |
Mean Error | \( Mean\ Error = \frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i) \) |
After obtaining the metrics for each tested model, the best model receives a score of 10, while the others receive scores of 9, 8, and so on.