Marshalling of 'raster' objects
# S3 method for RasterLayer
marshal(x, ...)
# S3 method for RasterLayer
marshallable(x, ...)
A raster:RasterLayer object.
Not used.
A marshalled
object as described in marshal()
.
raster::writeRaster()
is used to produce a marshalled version
of the original object.
raster::raster()
is used to reconstruct a version of the
original object from the marshalled object.
Marshalling of RasterLayer
objects is leaky. More precisely,
the method cannot guarantee that multiple rounds of marshalling
and unmarshalling produce numerically identical objects.
if (requireNamespace("raster", quietly = TRUE)) {
r <- raster::raster(system.file("external/test.grd", package = "raster"))
print(r)
## Marshal
r_ <- marshal(r)
## Unmarshal
r2 <- unmarshal(r_)
print(r2)
}
#> class : RasterLayer
#> dimensions : 115, 80, 9200 (nrow, ncol, ncell)
#> resolution : 40, 40 (x, y)
#> extent : 178400, 181600, 329400, 334000 (xmin, xmax, ymin, ymax)
#> crs : +proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +datum=WGS84 +units=m +no_defs
#> source : test.grd
#> names : test
#> values : 138.7071, 1736.058 (min, max)
#>
#> class : RasterLayer
#> dimensions : 115, 80, 9200 (nrow, ncol, ncell)
#> resolution : 40, 40 (x, y)
#> extent : 178400, 181600, 329400, 334000 (xmin, xmax, ymin, ymax)
#> crs : +proj=sterea +lat_0=52.1561605555556 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +datum=WGS84 +units=m +no_defs
#> source : filebeb4525ca69ce.grd
#> names : test
#> values : 139, 1736 (min, max)
#>