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.columns = spared_area.columns.astype(int) #year columns as int
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
grassland_area.columns = grassland_area.columns.astype(int)
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())
Combined land use dataframe
print(land.combined_future_land_use_area())
farm_id year land_use area_ha share_mineral \
0 -2020 2020 grassland 4.218508e+06 0.919424
1 -2020 2020 wetland 1.212500e+06 0.000047
2 -2020 2020 cropland 7.476981e+05 1.000000
3 -2020 2020 forest 7.300988e+05 0.472948
4 -2020 2020 settlement 1.261121e+05 0.984141
5 -2020 2020 farmable_condition 0.000000e+00 1.000000
6 0 2050 wetland 1.212500e+06 0.000047
7 0 2050 forest 2.571770e+06 0.850375
8 0 2050 cropland 7.476981e+05 1.000000
9 0 2050 farmable_condition 1.105181e+06 1.000000
10 0 2050 grassland 1.413048e+06 0.759448
11 0 2050 settlement 1.261121e+05 0.984141
12 1 2050 wetland 1.212500e+06 0.000047
13 1 2050 forest 3.575990e+06 0.892393
14 1 2050 cropland 7.476981e+05 1.000000
15 1 2050 farmable_condition 1.593243e+04 1.000000
16 1 2050 grassland 1.498077e+06 0.773102
17 1 2050 settlement 1.261121e+05 0.984141
18 2 2050 wetland 1.212500e+06 0.000047
19 2 2050 forest 8.714916e+05 0.558458
20 2 2050 cropland 7.476981e+05 1.000000
21 2 2050 farmable_condition 2.720430e+06 1.000000
22 2 2050 grassland 1.498077e+06 0.773102
23 2 2050 settlement 1.261121e+05 0.984141
24 3 2050 wetland 1.212500e+06 0.000047
25 3 2050 forest 8.714916e+05 0.558458
26 3 2050 cropland 7.476981e+05 1.000000
27 3 2050 farmable_condition 3.590237e+06 1.000000
28 3 2050 grassland 6.282709e+05 0.458974
29 3 2050 settlement 1.261121e+05 0.984141
share_organic share_drained_rich_organic share_drained_poor_organic \
0 0.080576 0.014650 0.017722
1 0.999953 0.000000 0.000000
2 0.000000 0.000000 0.000000
3 0.393645 0.000000 0.000000
4 0.015859 0.000000 0.000000
5 0.000000 0.000000 0.000000
6 0.999953 0.000000 0.000000
7 0.111752 0.000000 0.000000
8 0.000000 0.000000 0.000000
9 0.000000 0.000000 0.000000
10 0.240552 0.034660 0.041929
11 0.015859 0.000000 0.000000
12 0.999953 0.000000 0.000000
13 0.080369 0.000000 0.000000
14 0.000000 0.000000 0.000000
15 0.000000 0.000000 0.000000
16 0.226898 0.003067 0.003710
17 0.015859 0.000000 0.000000
18 0.999953 0.000000 0.000000
19 0.329779 0.000000 0.000000
20 0.000000 0.000000 0.000000
21 0.000000 0.000000 0.000000
22 0.226898 0.003067 0.003710
23 0.015859 0.000000 0.000000
24 0.999953 0.000000 0.000000
25 0.329779 0.000000 0.000000
26 0.000000 0.000000 0.000000
27 0.000000 0.000000 0.000000
28 0.541026 0.098367 0.118996
29 0.015859 0.000000 0.000000
share_rewetted_rich_organic share_rewetted_poor_organic \
0 0.021547 0.026644
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.000000 0.000000
7 0.000000 0.000000
8 0.000000 0.000000
9 0.000000 0.000000
10 0.073401 0.090521
11 0.000000 0.000000
12 0.000000 0.000000
13 0.000000 0.000000
14 0.000000 0.000000
15 0.000000 0.000000
16 0.098861 0.121222
17 0.000000 0.000000
18 0.000000 0.000000
19 0.000000 0.000000
20 0.000000 0.000000
21 0.000000 0.000000
22 0.098861 0.121222
23 0.000000 0.000000
24 0.000000 0.000000
25 0.000000 0.000000
26 0.000000 0.000000
27 0.000000 0.000000
28 0.144675 0.178898
29 0.000000 0.000000
share_organic_mineral share_rewetted_in_organic \
0 0.000000 0.000000
1 0.000000 0.007352
2 0.000000 0.000000
3 0.133407 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000000 0.007352
7 0.037873 0.000000
8 0.000000 0.000000
9 0.000000 0.000000
10 0.000000 0.000000
11 0.000000 0.000000
12 0.000000 0.007352
13 0.027237 0.000000
14 0.000000 0.000000
15 0.000000 0.000000
16 0.000000 0.000000
17 0.000000 0.000000
18 0.000000 0.007352
19 0.111762 0.000000
20 0.000000 0.000000
21 0.000000 0.000000
22 0.000000 0.000000
23 0.000000 0.000000
24 0.000000 0.007352
25 0.111762 0.000000
26 0.000000 0.000000
27 0.000000 0.000000
28 0.000000 0.000000
29 0.000000 0.000000
share_rewetted_in_mineral share_domestic_peat_extraction \
0 0.000000 0.000000
1 0.000047 0.072825
2 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.000047 0.000000
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.000047 0.000000
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.000047 0.000000
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
24 0.000047 0.000000
25 0.000000 0.000000
26 0.000000 0.000000
27 0.000000 0.000000
28 0.000000 0.000000
29 0.000000 0.000000
share_industrial_peat_extraction \
0 0.000000
1 0.045785
2 0.000000
3 0.000000
4 0.000000
5 0.000000
6 0.000000
7 0.000000
8 0.000000
9 0.000000
10 0.000000
11 0.000000
12 0.000000
13 0.000000
14 0.000000
15 0.000000
16 0.000000
17 0.000000
18 0.000000
19 0.000000
20 0.000000
21 0.000000
22 0.000000
23 0.000000
24 0.000000
25 0.000000
26 0.000000
27 0.000000
28 0.000000
29 0.000000
share_rewetted_industrial_peat_extraction \
0 0.000000
1 0.018910
2 0.000000
3 0.000000
4 0.000000
5 0.000000
6 0.064695
7 0.000000
8 0.000000
9 0.000000
10 0.000000
11 0.000000
12 0.064695
13 0.000000
14 0.000000
15 0.000000
16 0.000000
17 0.000000
18 0.064695
19 0.000000
20 0.000000
21 0.000000
22 0.000000
23 0.000000
24 0.064695
25 0.000000
26 0.000000
27 0.000000
28 0.000000
29 0.000000
share_rewetted_domestic_peat_extraction share_near_natural_wetland \
0 0.000000 0.000000
1 0.011881 0.718574
2 0.000000 0.000000
3 0.000000 0.000000
4 0.000000 0.000000
5 0.000000 0.000000
6 0.084706 0.718574
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.084706 0.718574
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.084706 0.718574
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
24 0.084706 0.718574
25 0.000000 0.000000
26 0.000000 0.000000
27 0.000000 0.000000
28 0.000000 0.000000
29 0.000000 0.000000
share_unmanaged_wetland share_burnt
0 0.000000 0.000103
1 0.089373 0.000277
2 0.000000 0.000019
3 0.000000 0.000418
4 0.000000 0.000000
5 0.000000 0.000000
6 0.089373 0.000261
7 0.000000 0.000283
8 0.000000 0.000064
9 0.000000 0.000000
10 0.000000 0.000164
11 0.000000 0.000000
12 0.089373 0.000261
13 0.000000 0.000283
14 0.000000 0.000064
15 0.000000 0.000000
16 0.000000 0.000164
17 0.000000 0.000000
18 0.089373 0.000261
19 0.000000 0.000287
20 0.000000 0.000064
21 0.000000 0.000000
22 0.000000 0.000164
23 0.000000 0.000000
24 0.089373 0.000261
25 0.000000 0.000287
26 0.000000 0.000064
27 0.000000 0.000000
28 0.000000 0.000164
29 0.000000 0.000000
Transition Matrix
print(transition.create_transition_matrix())
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.720430e+06 0.0 0.0
2 -2.720430e+06 0.0 0.0
3 -3.590237e+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.704498e+06 0.0
2 0.000000e+00 0.0
3 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.593243e+04 0.0
2 2.720430e+06 0.0
3 3.590237e+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 ...
3 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
3 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
3 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
3 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
3 0.0 0.0
Farmable_Condition_to_Farmable_Condition
-2020 0.0
0 0.0
1 0.0
2 0.0
3 0.0
[5 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 793471.392979
7 0 SGB YC6 340059.168420
8 0 Sitka YC20_24 396723.679300
9 0 SGB YC6 170024.433986
10 0 Sitka YC17_20 0.000000
11 0 SGB YC6 0.000000
12 1 Sitka YC24_30 795908.062041
13 1 SGB YC6 341103.455160
14 1 Sitka YC20_24 965626.893014
15 1 SGB YC6 413840.097006
16 1 Sitka YC17_20 131613.591886
17 1 SGB YC6 56405.825094
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
24 3 Sitka YC24_30 0.000000
25 3 SGB YC6 0.000000
26 3 Sitka YC20_24 0.000000
27 3 SGB YC6 0.000000
28 3 Sitka YC17_20 0.000000
29 3 SGB YC6 0.000000