Skip to content
Snippets Groups Projects
Commit dd2f3c51 authored by Maria Voigt's avatar Maria Voigt
Browse files

adding province and updating

parent 074dc765
Branches
No related tags found
No related merge requests found
...@@ -4,10 +4,12 @@ Spyder Editor ...@@ -4,10 +4,12 @@ Spyder Editor
# script to prepare the grid with the resource use information # script to prepare the grid with the resource use information
# in the output file we will have a # in the output file we will have a
# a 1 at the first position if pixel has to be discarded # a 1 at the first position if pixel has to be considered
# a 2 at the first position if the pixel is considered # a 2 at the first position if the pixel is discarded
# a 1 at the second position for IDN # a 1 at the second position for IDN
# a 2 at the second position for MYS # a 2 at the second position for MYS
# a 10 at the third position for SAB
# an 11 at the third position for SAW + also for others
# a 0 - 5 at the 3rd position depending on the resource use category # a 0 - 5 at the 3rd position depending on the resource use category
# the grid_id from the 4rth to the 10th position (6 positions) # the grid_id from the 4rth to the 10th position (6 positions)
# #
...@@ -16,13 +18,12 @@ Spyder Editor ...@@ -16,13 +18,12 @@ Spyder Editor
# 0 - absence # 0 - absence
# 1 - plantation # 1 - plantation
# 2 - deforestation # 2 - deforestation
# 3 - landcover change # 3 - logging
# 4 - logging # 4 - primary forest < 750m
# 5 - primary forest < 750m # 5 - primary forest > 750
# 6 - primary forest > 750 # 6 - regrowth
# 7 - regrowth # 7 - plantations before 2000
# 8 - plantations before 2000 # 8 - other
# 9 - other
""" """
...@@ -73,8 +74,11 @@ os.system("gdalwarp \ ...@@ -73,8 +74,11 @@ os.system("gdalwarp \
""" """
absence_path = "/homes/mv39zilo/work/Borneo/data/response/cleaned_data/absence_shape/absence_shape_expanded_22_08_17_repro_res.tif" #absence_path = "/homes/mv39zilo/work/Borneo/data/response/cleaned_data/absence_shape/absence_shape_expanded_22_08_17_repro_res.tif"
absence = mp.tiff.read_tif(absence_path, 1) #absence = mp.tiff.read_tif(absence_path, 1)
populations = mp.tiff.read_tif("/homes/mv39zilo/work/Borneo/data/populations_phva/meta_kalsarsab_20002015_diss_no_reintro_repro_res.tif", 1)
# input grid with grid_ids as values # input grid with grid_ids as values
...@@ -86,15 +90,31 @@ np.unique(resource_use) ...@@ -86,15 +90,31 @@ np.unique(resource_use)
country_layer_path = "/homes/mv39zilo/work/Borneo/data/auxiliary_additional_data/Borneo_shape/cleaned_data/Borneo_country_repro_res.tif" country_layer_path = "/homes/mv39zilo/work/Borneo/data/auxiliary_additional_data/Borneo_shape/cleaned_data/Borneo_country_repro_res.tif"
borneo = mp.tiff.read_tif(country_layer_path, 1) borneo = mp.tiff.read_tif(country_layer_path, 1)
province_layer_path = "/homes/mv39zilo/work/Borneo/data/auxiliary_additional_data/Borneo_shape/cleaned_data/Borneo_province_repro_res.tif"
borneo_province = mp.tiff.read_tif(province_layer_path, 1)
np.unique(borneo_province)
""" """
# format # format
1 0 0 0 0 0 000 000 1 0 10 0 000 001
(1 / 2) 0 (3 / 6) 0 (1-9) 0 700 000 (1 / 2) (3 / 6) 10-16 (1-9) 700 000
out/in, MYS/IDN, category,grid_id in/out, MYS/IDN, Province, category, grid_id
in/out
10000000000
country
1000000000
province
10000000
category
1000000
grid
100000
""" """
# pixel is out / out # pixel is in / out (in when 1, out when 2)
resource_grid_1 = np.where(absence == 1, 100000000000, 200000000000) resource_grid_1 = np.where(populations != 0, 10000000000, 20000000000)
# country # country
resource_grid_2 = np.where(borneo == 136, (resource_grid_1 + 3 * 1000000000), resource_grid_2 = np.where(borneo == 136, (resource_grid_1 + 3 * 1000000000),
...@@ -103,26 +123,29 @@ resource_grid_3 = np.where(borneo == 106, (resource_grid_2 + 6 * 1000000000), ...@@ -103,26 +123,29 @@ resource_grid_3 = np.where(borneo == 106, (resource_grid_2 + 6 * 1000000000),
resource_grid_2) resource_grid_2)
resource_grid_4 = np.where(resource_use > 0, (resource_grid_3 + resource_use * 10000000), # province
resource_grid_3) # excluding Brunei (1-4)
np.unique(resource_grid_4 ) resource_grid_4 = np.where(borneo_province > 4, (resource_grid_3 + (borneo_province * 10000000)), resource_grid_3)
# now assigning number for each resource use # now assigning number for each resource use
resource_grid_5 = np.where(resource_use > 0, (resource_grid_4 + resource_use * 1000000),
resource_grid_5 = np.where(grid > 0, (resource_grid_4 + grid), resource_grid_4)
resource_grid_4 )
np.unique(resource_grid_5) np.unique(resource_grid_5)
resource_grid_6 = np.where(grid > 0, (resource_grid_5 + grid),
resource_grid_5 )
np.unique(resource_grid_6)
mp.tiff.write_tif(file_with_srid = "/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/future/grid_with_id_repro_res.tif", mp.tiff.write_tif(file_with_srid = "/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/future/grid_with_id_repro_res.tif",
full_output_name = "/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/resource_use/resource_grid_absence_country_category_id.tif", full_output_name = "/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/resource_use/resource_grid_absence_country_category_id.tif",
data = resource_grid_5, data = resource_grid_6,
dtype = 5) dtype = 5)
# use this in R script "prepare_boot_grid.R" # use this in R script "prepare_boot_grid_resource_use.R"
""" """
...@@ -137,8 +160,8 @@ test = np.where((grid == 0) & ...@@ -137,8 +160,8 @@ test = np.where((grid == 0) &
np.sum(test) np.sum(test)
mp.tiff.write_tif(file_with_srid = grid_layer_path, mp.tiff.write_tif(file_with_srid = grid_layer_path,
full_output_name = "/homes/mv39zilo/work/Borneo/data/bootstrap/test.tif", full_output_name = "/homes/mv39zilo/work/Borneo/data/bootstrap/test.tif",
data = test, data = resource_grid_6,
dtype = 4) dtype = 5)
""" """
# rasterize borneo with info on country or province # rasterize borneo with info on country or province
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment