Skip to contents

Intended for SpatRasterImage which really is SpatRaster that also inherits from SPE's SpatialImage. Besides writeRaster, this function also writes a metadata file in the alabaster framework. If the image is not loaded into memory and the original file is already spatially registered, e.g. it has a spatial extent, then the original file is copied to a pre-defined place in the on-disk representation of SFE and writeRaster is not called.

Usage

# S4 method for class 'SpatRaster'
saveObject(x, path, ...)

Arguments

x

A Bioconductor object of the specified class.

path

String containing the path to a directory in which to save x.

...

Extra parameters passed to writeRaster.

Value

x is saved into path and NULL is invisibly returned.

See also

Examples

library(SFEData)
fp <- tempfile()
fn <- file.path(fp, "vizgen")
d <- VizgenOutput(dataset = "cellpose", file_path = fn)
#> see ?SFEData and browseVignettes('SFEData') for documentation
#> loading from cache
#> The downloaded files are in /tmp/RtmpfBErth/file2aa83324ff98/vizgen/vizgen_cellbound_Cellpose 
suppressWarnings(sfe <- readVizgen(d))
#> >>> 1 `.parquet` files exist:
#> /tmp/RtmpfBErth/file2aa83324ff98/vizgen/vizgen_cellbound_Cellpose/Cellpose/cellpose_micron_space.parquet
#> >>> using -> /tmp/RtmpfBErth/file2aa83324ff98/vizgen/vizgen_cellbound_Cellpose/Cellpose/cellpose_micron_space.parquet
#> >>> Cell segmentations are found in `.parquet` file
#> Sanity checks on cell segmentation polygons:
#> >>> ..found 1 cells with (nested) polygon lists
#> >>> ..applying filtering
#> >>> Casting MULTIPOLYGON geometry to POLYGON
#> >>> Checking polygon validity
img <- getImg(sfe)
class(img)
#> [1] "SpatRasterImage"
#> attr(,"package")
#> [1] "SpatialFeatureExperiment"
fsave <- file.path(fp, "img")
saveObject(img, fsave)
img2 <- readObject(fsave)