| serialize | R Documentation |
Because files created with IsoriX contain terra::SpatRaster and
terra::SpatVector objects, they cannot be saved using base::saveRDS
or base::save functions. The reason is that objects created with terra::terra
point to data stored in memory which are not contained in the R objects
themselves. Adapting the approach implemented in the terra::terra package, we
provide a wrapper for base::saveRDS and base::readRDS functions,
which allows one to save and read objects produced with IsoriX by simply
using saveRDS() and readRDS().
saveRDS_IsoriX(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S3 method for class 'ISOSCAPE'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S3 method for class 'CALIBFIT'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S3 method for class 'ISOFIND'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S3 method for class 'character'
readRDS(file, refhook = NULL)
## S4 method for signature 'ISOSCAPE'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S4 method for signature 'CALIBFIT'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S4 method for signature 'ISOFIND'
saveRDS(
object,
file = "",
ascii = FALSE,
version = NULL,
compress = TRUE,
refhook = NULL
)
## S4 method for signature 'character'
readRDS(file, refhook = NULL)
object |
(definition copied from |
file |
(definition copied from |
ascii |
(definition copied from |
version |
(definition copied from |
compress |
(definition copied from |
refhook |
(definition copied from |
base::saveRDS and base::readRDS are standard S3 functions. So in
order to be able to have a specific behaviour for objects produced with
IsoriX, we imported saveRDS and readRDS S4 generics from terra::terra to
dispatch both S3 and S4 IsoriX-specific methods (see Methods_for_S3). The
S3 implementation is consistent with the rest of the package and presents all
usual benefits associated with S3 methods (e.g. simple access to the code).
The S4 implementation makes IsoriX methods compatible with the use of
terra::saveRDS and terra::readRDS.
For saveRDS, NULL invisibly.
For readRDS, an R object.
saveRDS_IsoriX(): S3 function to save IsoriX objects into a RDS file
saveRDS(ISOSCAPE): S3 method to save an ISOSCAPE object into a RDS file
saveRDS(CALIBFIT): S3 method to save a CALIBFIT object into a RDS file
saveRDS(ISOFIND): S3 method to save an ISOFIND object into a RDS file
readRDS(character): S3 method to read an object produced with IsoriX (or other) stored in a RDS file
saveRDS(ISOSCAPE): S4 method to save an ISOSCAPE object into a RDS file
saveRDS(CALIBFIT): S4 method to save an CALIBFIT object into a RDS file
saveRDS(ISOFIND): S4 method to save an ISOFIND object into a RDS file
readRDS(character): S4 method to read an object produced with IsoriX (or other) stored in a RDS file
if (getOption_IsoriX("example_maxtime") > 30) {
## We prepare the data
GNIPDataDEagg <- prepsources(data = GNIPDataDE)
## We fit the models
GermanFit <- isofit(
data = GNIPDataDEagg,
mean_model_fix = list(elev = TRUE, lat_abs = TRUE)
)
## We build the isoscapes
GermanScape <- isoscape(raster = ElevRasterDE, isofit = GermanFit)
## Saving as RDS
filename <- tempfile(fileext = ".rds") # or whatever names you want
saveRDS(GermanScape, file = filename)
## Reading RDS
GermanScape2 <- readRDS(filename)
GermanScape2
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.