I'm hoping that someone might have already overcome this issue... I am trying to figure out some fragmentation metrics as part of a large loop in R (version 3.6.2) on a Mac. I'm having a problem with running out of memory when running through some particularly large input files. I feel like this issue might be able to be solved by having those files saved to my temp directory as this works well for the raster package - e.g. below:

> rasterOptions(tmpdir=file.path(TempDir_Home, LoopSp_FileName))

I have tried to make the landscapemetrics package do this in a variety of ways, e.g.:

> rasterOptions(tmpdir=file.path(TempDir_Home,LoopSp_FileName), todisk = TRUE)

or

> options(to_disk = TRUE)

or

> options_landscapemetrics(to_disk = NULL)

But none of these seem to fix the issue! So, I'm hoping that there's a work around or something!

My system is running MacOS Catalina with a 2.4 GHz 8-Core Intel Core i9 and 64 GB 2667 MHz DDR4 of RAM. At points my activity monitor suggests that my r session can be using > 200GB of memory while using calculate_lsm() and sometimes it runs out of memory before even getting to the progress output for the metrics.

Error Output now:

Error: vector memory exhausted (limit reached?)

In addition: Warning messages:

1: 'return_raster = TRUE' or 'to_disk = TRUE' not able for matrix input.

2: 'return_raster = TRUE' or 'to_disk = TRUE' not able for matrix input.

3: 'return_raster = TRUE' or 'to_disk = TRUE' not able for matrix input.

4: 'return_raster = TRUE' or 'to_disk = TRUE' not able for matrix input.

5: 'return_raster = TRUE' or 'to_disk = TRUE' not able for matrix input.

>

Raster info:

class : RasterLayer

dimensions : 37949, 40101, 1521792849 (nrow, ncol, ncell)

resolution : 100, 100 (x, y)

extent : -1888000, 2122100, -4798800, -1003900 (xmin, xmax, ymin, ymax)

crs : +proj=aea +lat_1=-18 +lat_2=-36 +lat_0=0 +lon_0=132 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs

source : /Users/.../Temp_Files/Braunsapis_unicolor/PresAbsRaster_loopBraunsapis_unicolor.grd

names : presence

values : 1, 1 (min, max)

NOTE: the values show presence data, with all other values being NA

More James Dorey's questions See All
Similar questions and discussions