Description Usage Arguments Examples
View source: R/results_spatialize_grasslandOverride.R
Takes the processed annual results from SALUS and turns into a spatial raster, based on the Experiment IDs - EXpID - and gridcell keys. Requires tidyverse, raster, and rgdal. Then overrides all grassland classes with 1
1 | spatializeGrass(expt_df0, variable, year, gridkey, template, aoi)
|
variable |
Variable to process |
year |
Year to process |
gridkey |
data.frame key linking ExpID and template gridcell |
template |
raster template |
aoi |
Area of interest to clip to defined by a spdf |
expt_df |
Data.frame containing SALUS annual results in long format, loaded with readr::read_csv |
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 | # load formatted results output
library(readr)
resultsDir <- 'C:/Users/deinesji/Dropbox/1PhdJill/hpa/LEMAs/data/salus/experiments/LEMA_historical_autoIrrigation_v02/results'
runname <- 'lema_historic_auto_v02'
expt_df <- read_csv(paste0(resultsDir, '/', runname, '.csv'))
# template raster
library(raster)
aeaProj <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
template <- raster(nrow = 4359, ncol = 7108, crs = aeaProj,
xmn = -522870, xmx = -309630, ymn = 1777860,
ymx = 1908630)
template[] <- 1:ncell(template)
# variable wanted
variable <- 'IRRC_mm'
year <- 2006
# load my grid key from r data...
comboDir <- 'C:/Users/deinesji/Dropbox/1PhdJill/hpa/LEMAs/data/salus/combinationGrids/spatialFilters'
load(file = paste0(comboDir,'/uniqueExperiments_gmd4p_Sheridan6_top6.RData'))
gridkey <- gridExps
rasterData <- spatialize(expt_df, variable, year, gridkey, template, aoi)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.