diff --git a/src/validation/grid_mapping_for_resource_use.py b/src/validation/grid_mapping_for_resource_use.py
index 092f97584b51bb6854d266b0ff68053b9ca7bb8b..18f126dff7bba4459807e1ad2bc5b86b70134161 100644
--- a/src/validation/grid_mapping_for_resource_use.py
+++ b/src/validation/grid_mapping_for_resource_use.py
@@ -4,10 +4,12 @@ Spyder Editor
 
 # script to prepare the grid with the resource use information
 # in the output file we will have a
-# a 1 at the first position if pixel has to be discarded
-# a 2 at the first position if the pixel is considered
+# a 1 at the first position if pixel has to be considered
+# a 2 at the first position if the pixel is discarded
 # a 1 at the second position for IDN
 # 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
 # the grid_id from the 4rth to the 10th position (6 positions)
 # 
@@ -16,13 +18,12 @@ Spyder Editor
 # 0 - absence       
 # 1 - plantation
 # 2 - deforestation
-# 3 - landcover change
-# 4 - logging
-# 5 - primary forest < 750m
-# 6 - primary forest > 750
-# 7 - regrowth
-# 8 - plantations before 2000
-# 9 - other 
+# 3 - logging
+# 4 - primary forest < 750m
+# 5 - primary forest > 750
+# 6 - regrowth
+# 7 - plantations before 2000
+# 8 - other 
 """
 
 
@@ -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 = mp.tiff.read_tif(absence_path, 1)
+#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)
+
+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
 
@@ -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"
 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
-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
+1              0        10        0          000 001
+(1 / 2)     (3 / 6)    10-16 (1-9)       700 000
+in/out,    MYS/IDN, Province,    category,   grid_id
+
+in/out
+10000000000
+country
+1000000000
+province
+10000000
+category
+1000000
+grid
+100000
 """
 
-# pixel is out / out
-resource_grid_1 = np.where(absence == 1, 100000000000, 200000000000)
+# pixel is in / out (in when 1, out when 2)
+resource_grid_1 = np.where(populations != 0, 10000000000, 20000000000)
 
 # country
 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),
                 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 )
-
+# province
+# excluding Brunei (1-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
-
-resource_grid_5 = np.where(grid > 0, (resource_grid_4 + grid), 
-                resource_grid_4 )
+resource_grid_5 = np.where(resource_use > 0, (resource_grid_4 + resource_use * 1000000), 
+                resource_grid_4)
 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", 
                    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)
      
-# 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) &
 np.sum(test)
 mp.tiff.write_tif(file_with_srid = grid_layer_path, 
                    full_output_name = "/homes/mv39zilo/work/Borneo/data/bootstrap/test.tif",
-                   data =  test, 
-                   dtype = 4)  
+                   data =  resource_grid_6, 
+                   dtype = 5)  
 """                
 # rasterize borneo with info on country or province