Save SpatRaster
to disk for alabaster
saveObject-SpatRaster-method.Rd
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.
See also
Other saveObject-SFE-image:
saveObject,BioFormatsImage-method
,
saveObject,ExtImage-method
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)