Skip to content

Saving an epmGrid object

ptitle edited this page Jan 12, 2022 · 2 revisions

On this page:

Link back to the table of contents.


Saving an epmGrid object

You can save an epmGrid object to file with the function write.epmGrid(), and load it in a new R session. All the data needed are self-contained in the file that is saved. The file that is created will appear as a .rds file.

write.epmGrid(squirrelEPM, "northAmericanSquirrels_epm.rds")

This file can then be read back into R with the function read.epmGrid().

squirrelEPM <- read.epmGrid("northAmericanSquirrels_epm.rds")

Saving an epmGrid object for GIS

You can also save the epmGrid object in a format that can then be loaded into GIS software, using the function writeEpmSpatial(). This function essentially passes along the epmGrid object to st_write() from the sf package, or to writeRaster() from the terra package, depending on what type of grid we are working with.

By default, a geopackage file is written for hexagonal grids, and a GeoTiff file is written for square-cell rasters. But it is also possible to write ESRI shapefiles or other formats. See the documentation for st_write or for writeRaster for more information.


Link back to the table of contents.

Clone this wiki locally