From 553bfa2b5d5fddcbba47bee12cc7aafd59a0e7e2 Mon Sep 17 00:00:00 2001
From: Maria Voigt <maria.voigt@idiv.de>
Date: Tue, 22 Aug 2017 11:17:15 +0200
Subject: [PATCH] deleting burnt and fixing bug in output

---
 .../grid_mapping_for_resource_use.py          | 49 +++++++++++++------
 1 file changed, 34 insertions(+), 15 deletions(-)

diff --git a/src/validation/grid_mapping_for_resource_use.py b/src/validation/grid_mapping_for_resource_use.py
index ed336f4..bc48511 100644
--- a/src/validation/grid_mapping_for_resource_use.py
+++ b/src/validation/grid_mapping_for_resource_use.py
@@ -12,12 +12,17 @@ Spyder Editor
 # the grid_id from the 4rth to the 10th position (6 positions)
 # 
 # now assigning number for each resource use
+# now assigning number for each resource use
 # 0 - absence       
 # 1 - plantation
 # 2 - deforestation
 # 3 - landcover change
 # 4 - logging
-# 5 - other 
+# 5 - primary forest < 750m
+# 6 - primary forest > 750
+# 7 - regrowth
+# 8 - plantations before 2000
+# 9 - other 
 """
 
 
@@ -79,28 +84,42 @@ np.unique(grid)
 resource_use = mp.tiff.read_tif("/homes/mv39zilo/work/Borneo/data/resource_use/resource_use_grid.tif", 1)
 np.unique(resource_use)  
 
+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)
+"""
+# format
+1        0    0     0   0   0 000 000
+(1 / 2)  0 (3 / 6)  0 (1-9) 0 700 000
+out/in,    MYS/IDN,  category,grid_id
+"""
 
 # pixel is out / out
-resource_grid_1 = np.where(absence == 1, 1000000000, 2000000000)
-resource_grid_2 = np.where(resource_use > 0, (resource_grid_1 + resource_use * 10000000), 
+resource_grid_1 = np.where(absence == 1, 100000000000, 200000000000)
+
+# country
+resource_grid_2 = np.where(borneo == 136, (resource_grid_1 + 3 * 1000000000), 
                 resource_grid_1)
-np.unique(resource_grid_2 )
+resource_grid_3 = np.where(borneo == 106, (resource_grid_2 + 6 * 1000000000), 
+                resource_grid_2)           
+                
+                
+resource_grid_4 = np.where(resource_use > 0, (resource_grid_3 + resource_use * 10000000), 
+                resource_grid_3)
+np.unique(resource_grid_4 )
+
+
+
+
  # now assigning number for each resource use
-# 0 - absence       
-# 1 - plantation
-# 2 - deforestation
-# 3 - landcover change
-# 4 - logging
-# 5 - other 
 
-resource_grid_3 = np.where(grid > 0, (resource_grid_2 + grid), 
-                resource_grid_2 )
-np.unique(resource_grid_3)
+resource_grid_5 = np.where(grid > 0, (resource_grid_4 + grid), 
+                resource_grid_4 )
+np.unique(resource_grid_5)
 
 
 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_3.tif",
-                   data = resource_grid_3, 
+                   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, 
                    dtype = 5)
      
 # use this in R script "prepare_boot_grid.R"
-- 
GitLab