import pandas as pd
import os
from landcover_assignment.transition_matrix import TransitionMatrix
from landcover_assignment.landcover import LandCover
from landcover_assignment.afforestation import Afforestation
Landcover Assignment Example
The landcover assignment module takes scenario inputs and inputs generated from the grassland_production module and distributes the spared area to various land uses. It considers soil type in the process (avaialbility of mineral or organic soils). It also considers soil groups in relation to the availability of organic soils and the forest yield class.
It produces the land use change dataframe for current and future land uses, as well as a transition matrix, and an afforestation dataframe that will then be used by the cbm_runner module
Set UP
input_path = "../tests/data/"
baseline = 2020 #the calibration year
target_year = 2050 #the target year
scenario_dataframe = pd.read_csv(os.path.join(input_path, "scenario_dataframe.csv"), index_col=0) #scenario inputs
spared_area = pd.read_csv(os.path.join(input_path, "spared_area.csv"), index_col=0) #total spared area
spared_area_breakdown = pd.read_csv(os.path.join(input_path, "spared_area_breakdown.csv"), index_col=0) #spared area by soil group
grassland_area = pd.read_csv(os.path.join(input_path, "total_grassland_area.csv"), index_col=0) #total grassland area remaining
Classes
The TransitionMatrix
class wil produce the transition matrix. While the LandCover
class produces the land use change dataframe, including the proportions of various soil types and other environmental factors.
Finally, the Afforestation
class produces the afforested area by yield class for use in the cbm_runner
module.
transition = TransitionMatrix(
baseline, target_year, scenario_dataframe, grassland_area, spared_area, spared_area_breakdown
)
land = LandCover(
baseline, target_year, scenario_dataframe, grassland_area, spared_area, spared_area_breakdown
)
affor = Afforestation(baseline, target_year, scenario_dataframe, transition.create_transition_matrix())
Land use Assignment Solution is optimal!
Land use Assignment Solution is optimal!
Land use Assignment Solution is optimal!
Combined land use dataframe
print(land.combined_future_land_use_area())
Land use Assignment Solution is optimal!
Land use Assignment Solution is optimal!
Land use Assignment Solution is optimal!
farm_id year land_use area_ha share_mineral \
0 -2020 2020 grassland 3.904877e+06 0.919536
1 -2020 2020 wetland 1.225154e+06 0.000231
2 -2020 2020 cropland 7.477145e+05 1.000000
3 -2020 2020 forest 7.764278e+05 0.681876
4 -2020 2020 settlement 1.269879e+05 0.974801
5 -2020 2020 farmable_condition 0.000000e+00 1.000000
6 0 2050 grassland 1.099417e+06 0.714212
7 0 2050 wetland 1.225154e+06 0.000231
8 0 2050 cropland 7.477145e+05 1.000000
9 0 2050 forest 2.476706e+06 0.900271
10 0 2050 settlement 1.269879e+05 0.974801
11 0 2050 farmable_condition 1.105181e+06 1.000000
12 1 2050 grassland 1.184394e+06 0.734716
13 1 2050 wetland 1.225154e+06 0.000231
14 1 2050 cropland 7.477145e+05 1.000000
15 1 2050 forest 3.480925e+06 0.929042
16 1 2050 settlement 1.269879e+05 0.974801
17 1 2050 farmable_condition 1.598606e+04 1.000000
18 2 2050 grassland 1.184394e+06 0.734716
19 2 2050 wetland 1.225154e+06 0.000231
20 2 2050 cropland 7.477145e+05 1.000000
21 2 2050 forest 7.764278e+05 0.681876
22 2 2050 settlement 1.269879e+05 0.974801
23 2 2050 farmable_condition 2.720483e+06 1.000000
share_organic share_drained_rich_organic share_drained_poor_organic \
0 0.080464 0.014561 0.017797
1 0.999769 0.000000 0.000000
2 0.000000 0.000000 0.000000
3 0.224747 0.000000 0.000000
4 0.025199 0.000000 0.000000
5 0.000000 0.000000 0.000000
6 0.285788 0.040120 0.049035
7 0.999769 0.000000 0.000000
8 0.000000 0.000000 0.000000
9 0.070456 0.000000 0.000000
10 0.025199 0.000000 0.000000
11 0.000000 0.000000 0.000000
12 0.265284 0.000000 0.000000
13 0.999769 0.000000 0.000000
14 0.000000 0.000000 0.000000
15 0.050130 0.000000 0.000000
16 0.025199 0.000000 0.000000
17 0.000000 0.000000 0.000000
18 0.265284 0.000000 0.000000
19 0.999769 0.000000 0.000000
20 0.000000 0.000000 0.000000
21 0.224747 0.000000 0.000000
22 0.025199 0.000000 0.000000
23 0.000000 0.000000 0.000000
share_rewetted_rich_organic share_rewetted_poor_organic \
0 0.021647 0.026458
1 0.000000 0.000000
2 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.088485 0.108148
7 0.000000 0.000000
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
12 0.119378 0.145906
13 0.000000 0.000000
14 0.000000 0.000000
15 0.000000 0.000000
16 0.000000 0.000000
17 0.000000 0.000000
18 0.119378 0.145906
19 0.000000 0.000000
20 0.000000 0.000000
21 0.000000 0.000000
22 0.000000 0.000000
23 0.000000 0.000000
share_organic_mineral share_rewetted_in_organic \
0 0.000000 0.000000
1 0.000000 0.003077
2 0.000000 0.000000
3 0.093376 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000000 0.003077
8 0.000000 0.000000
9 0.029273 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
12 0.000000 0.000000
13 0.000000 0.003077
14 0.000000 0.000000
15 0.020828 0.000000
16 0.000000 0.000000
17 0.000000 0.000000
18 0.000000 0.000000
19 0.000000 0.003077
20 0.000000 0.000000
21 0.093376 0.000000
22 0.000000 0.000000
23 0.000000 0.000000
share_rewetted_in_mineral share_domestic_peat_extraction \
0 0.000000 0.000000
1 0.000231 0.072073
2 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.000231 0.072073
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
12 0.000000 0.000000
13 0.000231 0.072073
14 0.000000 0.000000
15 0.000000 0.000000
16 0.000000 0.000000
17 0.000000 0.000000
18 0.000000 0.000000
19 0.000231 0.072073
20 0.000000 0.000000
21 0.000000 0.000000
22 0.000000 0.000000
23 0.000000 0.000000
share_industrial_peat_extraction \
0 0.0000
1 0.0635
2 0.0000
3 0.0000
4 0.0000
5 0.0000
6 0.0000
7 0.0635
8 0.0000
9 0.0000
10 0.0000
11 0.0000
12 0.0000
13 0.0635
14 0.0000
15 0.0000
16 0.0000
17 0.0000
18 0.0000
19 0.0635
20 0.0000
21 0.0000
22 0.0000
23 0.0000
share_rewetted_industrial_peat_extraction \
0 0.000000
1 0.030558
2 0.000000
3 0.000000
4 0.000000
5 0.000000
6 0.000000
7 0.030558
8 0.000000
9 0.000000
10 0.000000
11 0.000000
12 0.000000
13 0.030558
14 0.000000
15 0.000000
16 0.000000
17 0.000000
18 0.000000
19 0.030558
20 0.000000
21 0.000000
22 0.000000
23 0.000000
share_rewetted_domestic_peat_extraction share_near_natural_wetland \
0 0.000000 0.000000
1 0.011619 0.715462
2 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000000
7 0.011619 0.715462
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
12 0.000000 0.000000
13 0.011619 0.715462
14 0.000000 0.000000
15 0.000000 0.000000
16 0.000000 0.000000
17 0.000000 0.000000
18 0.000000 0.000000
19 0.011619 0.715462
20 0.000000 0.000000
21 0.000000 0.000000
22 0.000000 0.000000
23 0.000000 0.000000
share_unmanaged_wetland share_burnt
0 0.000000 0.000103
1 0.103481 0.000274
2 0.000000 0.000019
3 0.000000 0.000229
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.000103
7 0.103481 0.000274
8 0.000000 0.000019
9 0.000000 0.000072
10 0.000000 0.000000
11 0.000000 0.000000
12 0.000000 0.000103
13 0.103481 0.000274
14 0.000000 0.000019
15 0.000000 0.000051
16 0.000000 0.000000
17 0.000000 0.000000
18 0.000000 0.000103
19 0.103481 0.000274
20 0.000000 0.000019
21 0.000000 0.000229
22 0.000000 0.000000
23 0.000000 0.000000
Transition Matrix
print(transition.create_transition_matrix())
Land use Assignment Solution is optimal!
Land use Assignment Solution is optimal!
Land use Assignment Solution is optimal!
Grassland_to_Grassland Grassland_to_Wetland Grassland_to_Cropland \
-2020 0.000000e+00 0.0 0.0
0 -2.805460e+06 0.0 0.0
1 -2.720483e+06 0.0 0.0
2 -2.720483e+06 0.0 0.0
Grassland_to_Forest Grassland_to_Settlement \
-2020 0.000000e+00 0.0
0 1.700279e+06 0.0
1 2.704497e+06 0.0
2 0.000000e+00 0.0
Grassland_to_Farmable_Condition Wetland_to_Grassland \
-2020 0.000000e+00 0.0
0 1.105181e+06 0.0
1 1.598606e+04 0.0
2 2.720483e+06 0.0
Wetland_to_Wetland Wetland_to_Cropland Wetland_to_Forest ... \
-2020 0.0 0.0 0.0 ...
0 0.0 0.0 0.0 ...
1 0.0 0.0 0.0 ...
2 0.0 0.0 0.0 ...
Settlement_to_Cropland Settlement_to_Forest Settlement_to_Settlement \
-2020 0.0 0.0 0.0
0 0.0 0.0 0.0
1 0.0 0.0 0.0
2 0.0 0.0 0.0
Settlement_to_Farmable_Condition Farmable_Condition_to_Grassland \
-2020 0.0 0.0
0 0.0 0.0
1 0.0 0.0
2 0.0 0.0
Farmable_Condition_to_Wetland Farmable_Condition_to_Cropland \
-2020 0.0 0.0
0 0.0 0.0
1 0.0 0.0
2 0.0 0.0
Farmable_Condition_to_Forest Farmable_Condition_to_Settlement \
-2020 0.0 0.0
0 0.0 0.0
1 0.0 0.0
2 0.0 0.0
Farmable_Condition_to_Farmable_Condition
-2020 0.0
0 0.0
1 0.0
2 0.0
[4 rows x 36 columns]
Afforestation Dataframe
print(affor.gen_cbm_afforestation_dataframe(spared_area_breakdown))
scenario species yield_class total_area
0 -1 Sitka YC17_20 0.000000
1 -1 Sitka YC20_24 0.000000
2 -1 Sitka YC24_30 0.000000
3 -1 SGB YC6 0.000000
4 -1 SGB YC6 0.000000
5 -1 SGB YC6 0.000000
6 0 Sitka YC24_30 417595.058325
7 0 SGB YC6 715935.503074
8 0 Sitka YC20_24 208791.199405
9 0 SGB YC6 357956.899641
10 0 Sitka YC17_20 0.000000
11 0 SGB YC6 0.000000
12 1 Sitka YC24_30 418877.449812
13 1 SGB YC6 718134.067390
14 1 Sitka YC20_24 508198.559238
15 1 SGB YC6 871268.430782
16 1 Sitka YC17_20 69266.435907
17 1 SGB YC6 118752.125172
18 2 Sitka YC24_30 0.000000
19 2 SGB YC6 0.000000
20 2 Sitka YC20_24 0.000000
21 2 SGB YC6 0.000000
22 2 Sitka YC17_20 0.000000
23 2 SGB YC6 0.000000