Description Usage Arguments Details Value Author(s) Examples
View source: R/loadSimulations.R
Plume simulations for one scenario are a set of maps of the same area, each showing one plume.
This function generates a Simulations
object from all data of a scenario which can then be used to compute cost and to optimise sampling designs.
Data may extend the size of the memory; it can be provided either as raster maps or as values in text files (in this case spatial reference can be added later). The resulting values
are saved to disk as a raster
object.
1 2 3 | loadSimulations(basicPath = ".", readBy = NA,
multilayer = "kinds", region, bBox,
nameSave = NA, overwrite = FALSE, ...)
|
basicPath |
path to directory with files; it must not contain any but the files with simulations to be used |
multilayer |
way to interpret files with several layers/columns; |
readBy |
method to read the files; for some suffixes the reading method is determined automatically (all files must have the same suffix): |
region |
logical indicating in which locations to keep the values (for |
bBox |
bounding box of locations to keep, given as vector |
nameSave |
name to save resulting raster files that are created automatically and then contain the final data, files are created by appending names to it, starting with |
overwrite |
logical if files at |
... |
parameters to be forwarded to read.table and scan like |
Plume simulations have to be a set of maps all defined by values at the same set of locations; there may be several kinds of maps for each plume.
Such data can be loaded from files automatically if these have the following properties:
Files can either all be loaded by brick
(.grd/.gri, .tif) or by scan
(.txt, .csv). If they have one of the listed suffixes, the method is derived automatically; for other suffixes it must be given by the user in readBy
.
Each file must contain the values of a plume in all locations.
Files may contain several kinds of values; in this case each layer (of .tif or .grd files) or each column (in .txt or .csv files) belongs to different kind of map, the structure (number and meaning of columns/layers and rows) must be common to all files.
If there is only one kind of map, files may contain columns/layers with the values of several plumes.
File names must follow some rules:
They must not contain any "."
except the one to start the suffix.
They must not contain "_"
, except for the case described below; they are interpreted as the names of plumes.
If there are several kinds of maps, either all kinds for a plume are in the same file or there is a separate file for each kind and each plume. In the latter case file names must be of the form plumeName_kindName.suffix
. For each plume there must be a file for each kind.
The output of this function depends on the file type: raster files result in a Simulations
object, with spatial properties kept in the locations
(projection etc. of GeoTiff); text files do not contain spatial information, therefore a list
of plumes
and values
is returned that can be used to generate a Simulations
object together with appropriate locations
.
The function may generate (and overwrite or delete) files at nameSave
.
Kristina B. Helle, kristina.helle@uni-muenster.de
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 36 | ## Not run:
# examples for possible input is given in package sensors4plumesData in the
# subfolders of inst/extdata/fileFormats
# from raster files
Simulations1 = loadSimulations(
basicPath = paste0(path.package("sensors4plumesData"),
"/extdata/fileFormats/raster"),
nameSave = "t1_",
overwrite = TRUE
)
# from text files
Simulations2 = loadSimulations(
basicPath = paste0(path.package("sensors4plumesData"),
"/extdata/fileFormats/text_multicolumn"),
readBy = "scan",
nameSave = "t2_",
overwrite = TRUE,
skip = 1
)
# from multilayer raster files, selecting locations in a bounding box
region = as.logical(replicate(20, sample.int(2,1)) - 1)
bBox = c(0.2, 0.7, 0.4, 0.8)
Simulations3 = loadSimulations(
basicPath = paste0(path.package("sensors4plumesData"),
"/extdata/fileFormats/raster_multilayer"),
nameSave = "t3_",
region = region,
bBox = bBox,
overwrite = TRUE
)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.