save_mland | R Documentation |
Exports an object of class 'MultiLand' to be read in the future with load_mland()
, or
an object of class 'MultiLandMetrics' as if it was saved with saveRDS()
.
save_mland(
x,
name = NULL,
gdal = c("COMPRESS=DEFLATE", "PREDICTOR=2", "ZLEVEL=9"),
...
)
x |
Object of class 'MultiLand' or 'MultiLandMetrics'. |
name |
If |
gdal |
GDAL driver specific datasource creation options. See the GDAL documentation. With the
GeoTiff file format, |
... |
If |
'MultiLand' objects should be exported with this function rather than exporting as an
external representation of R objects with saveRDS()
. This is because objects of classes
'SpatVector' and 'SpatRaster' (from package terra) contained inside a 'MultiLand'
object cannot be exported as regular R objects. The exported object will be a zip file,
and can be loaded again into an R session with load_mland()
.
Relevant arguments can be passed to the function terra::writeRaster, which is used to write
rasterlayers from a 'MultiLand' object. Particularly, in the argument gdal
one can specify
relevant options regarding raster compression. This may reduce raster sizes significantly. Definition
of some other arguments inside terra::writeRaster may affect exportation of rasterlayer
objects, in the context of a 'MultiLand' object.
Objects of class 'MultiLandMetrics', instead, do not contain 'SpatVector' or 'SpatRaster' objects
and can be exported as regular R objects with saveRDS()
. The user may use saveRDS()
or
save_mland()
, and the outcome will be identical.
If x
is an object of class 'MultiLand', a zip file or a directory containing all
information regarding the 'MultiLand' object provided in 'x'. Otherwise, if x
is an object of
class 'MultiLandMetrics', the function will export the R object as if it was exported as a
regular R object with saveRDS()
.
load_mland()
, mland()
, metrics()
## Not run:
# Load MultiLand object
mland_obj <- system.file("extdata", "ernesdesign.zip", package = "multilandr")
ernesdesign2 <- load_mland(mland_obj)
# Save it again
save_mland(ernesdesign2)
# Save it again but defining a higher compression for rasterlayers
save_mland(ernesdesign2, gdal = "COMPRESS=DEFLATE")
# Loads a MultiLandMetrics object previously generated with metrics()
mlm_obj <- system.file("extdata", "ed_metrics.rds", package = "multilandr")
ed_metrics2 <- load_mland(mlm_obj)
# Save it again. In this case, save_mland() is the same as using saveRDS()
save_mland(ed_metrics2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.