Create and Export mosaics
Usage
mosaic_input(
mosaic,
mosaic_pattern = NULL,
info = TRUE,
check_16bits = FALSE,
check_datatype = FALSE,
...
)
mosaic_export(mosaic, filename, datatype = NULL, overwrite = FALSE, ...)
Arguments
- mosaic
For
mosaic_input()
, a file path to the raster to imported, a matrix, array or a list ofSpatRaster
objects.For
mosaic_export()
, anSpatRaster
object.
- mosaic_pattern
A pattern name to import multiple mosaics into a list.
- info
Print the mosaic informations (eg., CRS, extend). Defaults to
TRUE
- check_16bits
Checks if mosaic has maximum value in the 16-bits format (65535), and replaces it by NA. Defaults to
FALSE
.- check_datatype
Logical. If
TRUE
, checks and suggests the appropriate data type based on the raster values.- ...
Additional arguments passed to
terra::rast()
(mosaic_input()
) orterra::writeRaster()
(mosaic_output()
)- filename
character. The Output filename.
- datatype
The datatype. By default, the function will try to guess the data type that saves more memory usage and file size. See
terra::writeRaster()
andterra::datatype()
for more details.- overwrite
logical. If
TRUE
, filename is overwritten.
Details
mosaic_input()
is a simply wrapper aroundterra::rast()
. It creates aSpatRaster
object from scratch, from a filename, or from another object.mosaic_export()
is a simply wrapper aroundterra::writeRaster()
. It write aSpatRaster
object to a file.
Examples
if (interactive() && requireNamespace("EBImage")) {
library(pliman)
# create an SpatRaster object based on a matrix
x <- system.file("ex/logo.tif", package="terra")
rast <- mosaic_input(x)
mosaic_plot(rast)
# create a temporary filename for the example
f <- file.path(tempdir(), "test.tif")
mosaic_export(rast, f, overwrite=TRUE)
list.files(tempdir())
}
#> class : SpatRaster
#> dimensions : 77, 101, 3 (nrow, ncol, nlyr)
#> resolution : 1, 1 (x, y)
#> extent : 0, 101, 0, 77 (xmin, xmax, ymin, ymax)
#> coord. ref. : Cartesian (Meter)
#> source : logo.tif
#> colors RGB : 1, 2, 3
#> names : red, green, blue
#> min values : 0, 0, 0
#> max values : 255, 255, 255
#> Exporting the mosaic using datatype = INT1U
#> [1] "Rf62f418c29fb"
#> [2] "data_stars62f419fb2489_fb8c50"
#> [3] "data_stars62f4241374d2_6382d5"
#> [4] "downlit"
#> [5] "downloaded_packages"
#> [6] "file62f4444c27b1"
#> [7] "file62f44d09386f"
#> [8] "file62f46c885600"
#> [9] "file62f478e54998"
#> [10] "file62f47d029f3"
#> [11] "foo.dll"
#> [12] "foo.o"
#> [13] "git-commit-message-62f432e01ac5.txt"
#> [14] "libloc_181_c7e167d9.rds"
#> [15] "libloc_185_fc06ca9c.rds"
#> [16] "libloc_197_7764dce8.rds"
#> [17] "libloc_197_ac7c3ef3.rds"
#> [18] "pkgload62f436ff257"
#> [19] "pkgload62f4471366d"
#> [20] "pkgload62f47ec92f92"
#> [21] "repos_https%3A%2F%2Fcran.rstudio.com%2Fbin%2Fwindows%2Fcontrib%2F4.4.rds"
#> [22] "repos_https%3A%2F%2Fcran.rstudio.com%2Fsrc%2Fcontrib.rds"
#> [23] "rs-graphics-3c45e660-992d-4263-a5b0-143a4bcc9f28"
#> [24] "temp_libpath62f46be42b72"
#> [25] "test.tif"
#> [26] "test.tif.aux.xml"
#> [27] "viewhtml62f420e7764e"