-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmap_grass_pathway_exampleScript.R
More file actions
35 lines (27 loc) · 1 KB
/
map_grass_pathway_exampleScript.R
File metadata and controls
35 lines (27 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# map_grass_pathway: Wrapper script to predict C4/C3 grass proportions
# Example Script [Save output to File]
# Set working directory
setwd("...")
# Load required R libraries
library(raster)
library(rgdal)
library(grassmapr)
# Load data for example
data(temp_NA) # mean monthly temperature (deg. C)
data(prec_NA) # mean monthly precipitation (mm)
# Specify climate thresholds
C4_temp <- 22 # mean monthly temperature >= 22 deg. C
GS_temp <- 5 # mean monthly temperature >= 5 deg. C
GS_prec <- 25 # mean monthly precipitation >= 25 mm
# Predict percent of grasses by photosynthetic pathway.
map_grass_pathway(temp.stack = temp_NA,
precip.stack = prec_NA,
C4.threshold = C4_temp,
GS.threshold = GS_temp,
precip.threshold = GS_prec,
filename = "./grass_map")
# Plot C4 and C3 grass layers.
grass_map <- brick("./grass_map.tif")
names(grass_map) <- c("C4.proportion", "C3.proportion")
par(mfrow = c(1,2))
plot(grass_map)