This function retrieves spatial columns from one or more SyncroSim Scenario Datasheets.

datasheetRaster(
  ssimObject,
  datasheet,
  column = NULL,
  scenario = NULL,
  iteration = NULL,
  timestep = NULL,
  subset = NULL,
  forceElements = FALSE
)

# S4 method for character
datasheetRaster(
  ssimObject,
  datasheet,
  column = NULL,
  scenario = NULL,
  iteration = NULL,
  timestep = NULL,
  subset = NULL,
  forceElements = FALSE
)

# S4 method for list
datasheetRaster(
  ssimObject,
  datasheet,
  column = NULL,
  scenario = NULL,
  iteration = NULL,
  timestep = NULL,
  subset = NULL,
  forceElements = FALSE
)

# S4 method for SsimObject
datasheetRaster(
  ssimObject,
  datasheet,
  column = NULL,
  scenario = NULL,
  iteration = NULL,
  timestep = NULL,
  subset = NULL,
  forceElements = FALSE
)

# S4 method for Scenario
datasheetRaster(
  ssimObject,
  datasheet,
  column = NULL,
  scenario = NULL,
  iteration = NULL,
  timestep = NULL,
  subset = NULL,
  forceElements = FALSE
)

Arguments

ssimObject

SsimLibrary/Project/Scenario object or list of Scenario objects. If SsimLibrary/Project, then scenario argument is required

datasheet

character string. The name of the Datasheet containing the raster data

column

character string. The name of the column in the datasheet containing the file names for raster data. If NULL (default) then use the first column that contains raster file names

scenario

character string, integer, or vector of these. The Scenarios to include. Required if SsimObject is an SsimLibrary/Project, ignored if SsimObject is a list of Scenarios (optional)

iteration

integer, character string, or vector of integer/character strings. Iteration(s) to include. If NULL (default) then all iterations are included. If no Iteration column is in the Datasheet, then ignored

timestep

integer, character string, or vector of integer/character string. Timestep(s) to include. If NULL (default) then all timesteps are included. If no Timestep column is in the Datasheet, then ignored

subset

logical expression indicating Datasheet rows to return. e.g. expression(grepl("Ts0001", Filename, fixed=T)). See subset() for details (optional)

forceElements

logical. If TRUE then returns a single raster as a RasterStack; otherwise returns a single raster as a RasterLayer directly. Default is FALSE

Value

A RasterLayer, RasterStack or RasterBrick object. See raster package documentation for details.

Details

The names of the returned raster stack contain metadata. For Datasheets without Filename this is:

paste0(<datasheet name>,".Scn",<scenario id>,".",<tif name>).

For Datasheets containing Filename this is:

paste0(<datasheet name>,".Scn",<scenario id>,".It",<iteration>,".Ts",<timestep>).

Examples

# \donttest{ # Install the helloworldSpatial package from the server addPackage("helloworldSpatial")
#> Package <helloworldSpatial> is already installed
# Specify file path and name of new SsimLibrary myLibraryName <- file.path(tempdir(), "testlib_datasheetRaster") # Set up a SyncroSim Session mySession <- session() # Use the example template library from helloworldSpatial myLibrary <- ssimLibrary(name = myLibraryName, session = mySession, package = "helloworldSpatial", template = "example-library", overwrite=TRUE)
#> Scenarios available in this template: My Scenario
# Set up Project and Scenario myProject <- project(myLibrary, project = "Definitions") myScenario <- scenario(myProject, scenario = "My Scenario") # Run Scenario to generate results resultScenario <- run(myScenario)
#> [1] "Running scenario [1] My Scenario"
# Extract specific Datasheet rasters by iteration and timestep resultRaster <- datasheetRaster(resultScenario, datasheet = "IntermediateDatasheet", column = "OutputRasterFile", iteration = 3, timestep = 2 ) # Extract specific Datasheet rasters using pattern matching resultDatasheet <- datasheet(resultScenario, name = "IntermediateDatasheet") head(resultDatasheet)
#> Iteration Timestep y #> 1 1 1 -344.1105 #> 2 1 2 -683.8870 #> 3 1 3 -1023.6634 #> 4 1 4 -1363.4399 #> 5 1 5 -1703.2164 #> 6 1 6 -2042.9929 #> OutputRasterFile #> 1 C:\\Users\\birch\\AppData\\Local\\Temp\\RtmpiArgKt\\testlib_datasheetRaster.ssim.input\\Scenario-2\\helloworldSpatial_IntermediateDatasheet\\rasterMap_iter1_ts1.tif #> 2 C:\\Users\\birch\\AppData\\Local\\Temp\\RtmpiArgKt\\testlib_datasheetRaster.ssim.input\\Scenario-2\\helloworldSpatial_IntermediateDatasheet\\rasterMap_iter1_ts2.tif #> 3 C:\\Users\\birch\\AppData\\Local\\Temp\\RtmpiArgKt\\testlib_datasheetRaster.ssim.input\\Scenario-2\\helloworldSpatial_IntermediateDatasheet\\rasterMap_iter1_ts3.tif #> 4 C:\\Users\\birch\\AppData\\Local\\Temp\\RtmpiArgKt\\testlib_datasheetRaster.ssim.input\\Scenario-2\\helloworldSpatial_IntermediateDatasheet\\rasterMap_iter1_ts4.tif #> 5 C:\\Users\\birch\\AppData\\Local\\Temp\\RtmpiArgKt\\testlib_datasheetRaster.ssim.input\\Scenario-2\\helloworldSpatial_IntermediateDatasheet\\rasterMap_iter1_ts5.tif #> 6 C:\\Users\\birch\\AppData\\Local\\Temp\\RtmpiArgKt\\testlib_datasheetRaster.ssim.input\\Scenario-2\\helloworldSpatial_IntermediateDatasheet\\rasterMap_iter1_ts6.tif
resultRaster <- datasheetRaster(resultScenario, datasheet = "IntermediateDatasheet", column = "OutputRasterFile", subset = expression(grepl("ts20", resultDatasheet$OutputRasterFile, fixed = TRUE)) )
#> Error in grepl("ts20", resultDatasheet$OutputRasterFile, fixed = TRUE): object 'resultDatasheet' not found
# Return the raster Datasheets as a raster stack resultRaster <- datasheetRaster(resultScenario, datasheet = "IntermediateDatasheet", column = "OutputRasterFile", forceElements = TRUE ) # }