Description Usage Arguments Details Value See Also Examples
function to reclassify values of a raster object or raster file based on a reclassification matrix which specifies which value in the output should be taken by different intervals of values of the input raster (simple wrapper for the raster::reclassify function, providing a (somehow) easier and extended I/O functionality)
1 2 | reclass_rast(in_rast, reclass_matrix, to_file = FALSE, out_rast = NULL,
overwrite = FALSE)
|
in_rast |
Input raster file or "R" raster layer to be reclassified |
reclass_matrix |
|
to_file |
|
out_rast |
|
overwrite |
|
reclass_matrix
must be a 3-columns data.frame
(or similar), including the start
, end
and
new
columns. It can be easily created by, for example:
1 2 3 4 5 6 7 |
, or:
1 2 3 |
if to_file == FALSE: *raster
corresponding to the reclassified raster
if to_file == TRUE: name of the file where it was saved (either corresponding to out_rast
or to the name of the temporary file created (if out_rast == NULL
))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
# reclassify a land cover map with N classes to a 0-1 mask, retaining classes 5 and 9, putting
# the rest to 0 and values >= 11 to NA
# Open the masking file
in_mask <- raster(in_maskfile)
# setup the reclassification matrix
reclass_matrix <- tibble::tribble(
~start, ~end, ~new,
0, 0, NA,
1, 5, 0,
5, 6, 1,
6, 9, 1,
9, 11, 1,
11, 100, NA)
reclass_file = "/home/lb/Temp/buttami/pippo_reclass.tif"
outmask = reclass_rast(in_rast,
reclass_matrix,
r_out = TRUE)
plot(outmask)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.