Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
manuscript_code
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maria Voigt
manuscript_code
Commits
46852746
Commit
46852746
authored
7 years ago
by
Maria Voigt
Browse files
Options
Downloads
Patches
Plain Diff
deleting landcover change
parent
d026855a
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/resource_use/preparing_grid_resource_use.py
+33
-40
33 additions, 40 deletions
src/resource_use/preparing_grid_resource_use.py
with
33 additions
and
40 deletions
src/resource_use/preparing_grid_resource_use.py
+
33
−
40
View file @
46852746
...
@@ -91,13 +91,12 @@ np.unique(grid)
...
@@ -91,13 +91,12 @@ np.unique(grid)
# 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
gaveau_defor_path
=
"
/homes/mv39zilo/work/Borneo/data/predictors/raw_data/Remaining_forest_in_2015_and_deforestation_1973-2015/REGIONBorneo_FCDefDeg_1973to2015_CIFOR_repro_res.tif
"
gaveau_defor_path
=
"
/homes/mv39zilo/work/Borneo/data/predictors/raw_data/Remaining_forest_in_2015_and_deforestation_1973-2015/REGIONBorneo_FCDefDeg_1973to2015_CIFOR_repro_res.tif
"
...
@@ -112,16 +111,6 @@ gaveau_regrowth = np.where(gaveau_defor_raw == 4, 1, 0)
...
@@ -112,16 +111,6 @@ gaveau_regrowth = np.where(gaveau_defor_raw == 4, 1, 0)
plantation_path
=
"
/homes/mv39zilo/work/Borneo/data/predictors/raw_data/Land_cover_trajectory_before_oil-palm_and_pulpwood_establishment/raster_plantation.tif
"
plantation_path
=
"
/homes/mv39zilo/work/Borneo/data/predictors/raw_data/Land_cover_trajectory_before_oil-palm_and_pulpwood_establishment/raster_plantation.tif
"
plantations
=
mp
.
tiff
.
read_tif
(
plantation_path
,
1
)
plantations
=
mp
.
tiff
.
read_tif
(
plantation_path
,
1
)
#non habitat
crisp_2000_path
=
"
/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/resource_use//crisp_2000_repro_res.tif
"
crisp_2000
=
mp
.
tiff
.
read_tif
(
crisp_2000_path
,
1
)
crisp_2010_path
=
"
/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/resource_use/crisp_2010_repro_res.tif
"
crisp_2010
=
mp
.
tiff
.
read_tif
(
crisp_2010_path
,
1
)
crisp_2015_path
=
"
/homes/mv39zilo/work/Borneo/analysis/model_prep_and_running/results/resource_use/crisp_2015_repro_res.tif
"
crisp_2015
=
mp
.
tiff
.
read_tif
(
crisp_2015_path
,
1
)
cover_change
=
np
.
where
(((
crisp_2000
>
2
)
&
(
crisp_2000
<
7
))
&
((
crisp_2010
>
6
)
|
(
crisp_2010
==
1
)
|
(
crisp_2015
>
6
)
|
(
crisp_2015
==
1
)
),
1
,
0
)
# old plantations
# old plantations
old_plantations_path
=
"
/homes/mv39zilo/work/Borneo/data/predictors/raw_data/Land_cover_trajectory_before_oil-palm_and_pulpwood_establishment/raster_plantation_old_repro_res.tif
"
old_plantations_path
=
"
/homes/mv39zilo/work/Borneo/data/predictors/raw_data/Land_cover_trajectory_before_oil-palm_and_pulpwood_establishment/raster_plantation_old_repro_res.tif
"
old_plantations
=
mp
.
tiff
.
read_tif
(
old_plantations_path
,
1
)
old_plantations
=
mp
.
tiff
.
read_tif
(
old_plantations_path
,
1
)
...
@@ -148,43 +137,38 @@ grid = np.where((plantations == 0) &
...
@@ -148,43 +137,38 @@ grid = np.where((plantations == 0) &
(
gaveau_deforested
==
1
)
&
(
gaveau_deforested
==
1
)
&
(
grid
==
1
),
2
,
grid
)
(
grid
==
1
),
2
,
grid
)
# 3 cover change
# 3 logged
grid
=
np
.
where
((
plantations
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
cover_change
==
1
)
&
(
grid
==
1
),
3
,
grid
)
# 4 logged
grid
=
np
.
where
((
plantations
==
0
)
&
grid
=
np
.
where
((
plantations
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
cover_change
==
0
)
&
(
cover_change
==
0
)
&
(
gaveau_logged
==
1
)
&
(
gaveau_logged
==
1
)
&
(
grid
==
1
),
4
,
grid
)
(
grid
==
1
),
3
,
grid
)
#
5
primary forest
#
4
primary forest
grid
=
np
.
where
((
plantations
==
0
)
&
grid
=
np
.
where
((
plantations
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
cover_change
==
0
)
&
(
cover_change
==
0
)
&
(
gaveau_logged
==
0
)
&
(
gaveau_logged
==
0
)
&
(
gaveau_primary_forest
==
1
)
&
(
gaveau_primary_forest
==
1
)
&
(
grid
==
1
),
5
,
grid
)
(
grid
==
1
),
4
,
grid
)
# add here primary forest at high altitudes
# add here primary forest at high altitudes
# because everywhere where we have primary forest
# because everywhere where we have primary forest
# we no longer have a 1 in grid but a six we do it differently
# we no longer have a 1 in grid but a six we do it differently
#
6
primary montane
#
5
primary montane
grid
=
np
.
where
((
grid
==
5
)
&
grid
=
np
.
where
((
grid
==
4
)
&
(
dem
>
750
),
6
,
grid
)
(
dem
>
750
),
5
,
grid
)
#
7
regrowth
#
6
regrowth
grid
=
np
.
where
((
plantations
==
0
)
&
grid
=
np
.
where
((
plantations
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
cover_change
==
0
)
&
(
cover_change
==
0
)
&
(
gaveau_logged
==
0
)
&
(
gaveau_logged
==
0
)
&
(
gaveau_primary_forest
==
0
)
&
(
gaveau_primary_forest
==
0
)
&
(
gaveau_regrowth
==
1
)
&
(
gaveau_regrowth
==
1
)
&
(
grid
==
1
),
7
,
grid
)
(
grid
==
1
),
6
,
grid
)
#
8
is old plantations
#
7
is old plantations
grid
=
np
.
where
((
plantations
==
0
)
&
grid
=
np
.
where
((
plantations
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
gaveau_deforested
==
0
)
&
...
@@ -193,18 +177,18 @@ grid = np.where((plantations == 0) &
...
@@ -193,18 +177,18 @@ grid = np.where((plantations == 0) &
(
gaveau_primary_forest
==
0
)
&
(
gaveau_primary_forest
==
0
)
&
(
gaveau_regrowth
==
0
)
&
(
gaveau_regrowth
==
0
)
&
(
old_plantations
==
1
)
&
(
old_plantations
==
1
)
&
(
grid
==
1
),
8
,
grid
)
(
grid
==
1
),
7
,
grid
)
#
9
is other
#
8
is other
grid
=
np
.
where
((
plantations
==
0
)
&
grid
=
np
.
where
((
plantations
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
gaveau_deforested
==
0
)
&
(
cover_change
==
0
)
&
(
cover_change
==
0
)
&
(
gaveau_logged
==
0
)
&
(
gaveau_logged
==
0
)
&
(
gaveau_primary_forest
==
0
)
&
(
gaveau_primary_forest
==
0
)
&
(
gaveau_regrowth
==
0
)
&
(
gaveau_regrowth
==
0
)
&
(
grid
==
1
),
9
,
grid
)
(
grid
==
1
),
8
,
grid
)
np
.
unique
(
grid
)
np
.
unique
(
grid
)
...
@@ -215,12 +199,21 @@ mp.tiff.write_tif(file_with_srid = grid_layer_path,
...
@@ -215,12 +199,21 @@ mp.tiff.write_tif(file_with_srid = grid_layer_path,
dtype
=
0
)
dtype
=
0
)
# grid map with three categories
# grid map with four categories
# 0 - absence - 0
grid_map
=
np
.
where
((
grid
<
5
)
&
# 1 - plantation - 1
# 2 - deforestation - 1
# 3 - logging - 1
# 4 - primary forest < 750m - 2
# 5 - primary forest > 750 - 2
# 6 - regrowth - 2
# 7 - plantations before 2000 - 3
# 8 - other - 3
grid_map
=
np
.
where
((
grid
<=
3
)
&
(
grid
>
0
),
1
,
0
)
(
grid
>
0
),
1
,
0
)
grid_map
=
np
.
where
((
grid
<
7
)
&
grid_map
=
np
.
where
((
grid
<
=
6
)
&
(
grid
>
4
),
2
,
grid_map
)
(
grid
>
3
),
2
,
grid_map
)
grid_map
=
np
.
where
((
grid
>
6
),
3
,
grid_map
)
grid_map
=
np
.
where
((
grid
>
6
),
3
,
grid_map
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment