split_replace {geoTS} | R Documentation |
Splits a Raster* object into smaller chunks and allows to replace cell values
Description
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
.
Usage
split_replace(
raster,
partPerSide,
h,
v,
outputPath,
name,
save = TRUE,
replace = FALSE,
valToReplace,
replacedBy,
dataType,
format = "GTiff",
parallelProcessing = FALSE,
numCores = 20,
cellsToProcess,
...
)
Arguments
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 |
Details
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.
Value
At outputPath
the user will find length(cellsToProcess)
Raster* files
See Also
writeRaster
, aggregate
,
rasterOptions