View source: R/split_replace.R
split_replace | R Documentation |
This function will split a Raster* object into smaller chunks. The size of these chunks (number of cells)
is controlled by partPerSide
, h
or v
. Additionally, it allows to replace cell values (valToReplace
)
within Raster* object by another value of user's choice (replacedBy
). When save = TRUE
,
the resulting cellsToProcess
Raster* objects are saved in directory outputPath
.
split_replace( raster, partPerSide, h, v, outputPath, name, save = TRUE, replace = FALSE, valToReplace, replacedBy, dataType, format = "GTiff", parallelProcessing = FALSE, numCores = 20, cellsToProcess, ... )
raster |
Raster* object. |
partPerSide |
integer indicating number of cells in which |
h |
integer indicating number of horizontal cells in which |
v |
integer indicating number of vertical cells in which |
outputPath |
character with full path name where the resulting Raster* objects will be saved. |
name |
character with the name to assign to final products. |
save |
logical, should the output be saved, default is |
replace |
logical, default |
valToReplace |
indicates a value to be replaced across |
replacedBy |
indicates the value by which |
dataType |
character, output data type. See |
format |
character, output file type, default |
parallelProcessing |
logical, default |
numCores |
numeric indicating the number of cores used in parallel processing. |
cellsToProcess |
numeric vector indicating which smaller cells should be processed/saved. See Details. |
... |
additional arguments used by |
Before processing any of the cellsToProcess
the temporary raster
directory is re-directed. Basically, prior to process the i-th cell,
at outputPath
a new subdirectory is created, which, in turn, is erased
automatically once the i-th cell has been processed. As a result of several tests
we found that this measure avoids memory overflow.
When partPerSide
is used, cellsToProcess = 1:(partPerSide^2)
. When h
and v
are used, cellsToProcess = 1:(ncells(raster)/(h*v))
. Since the code
assumes that nrow(raster)
and ncol(raster)
are multiples of partPerSide
or h
and v
, respectively, the user must be careful when selecting these
parameters.
For parallelProcessing
the backend doParallel
is employed.
At outputPath
the user will find length(cellsToProcess)
Raster* files
writeRaster
, aggregate
,
rasterOptions
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.