R raster package: memory shortage when using “getValuesFocal” function -
With 3 layers, I would like to calculate the focal length for raster (1300 cells by 1400 cells) and I use the data from all 3 layers.
. For example, one of the layers is a land cover map and I would like to use only in pixels calculation in the focal window, whose equal land cover type is in the form of central pixels of the window. I think this is not possible with the "focal" function in the raster package, so I tried to extract the data from the 3 layers for the limit of each moving window by "getValuesFocal" after doing this, after considering the result of "getValuesFocal" array The lines were of loop though the array is too large and is not fit in memory so I get an error message:
dataraster & lt; - Stack (classification, layer 2, layer 3) data & lt; - getValuesFocal (dataraster, ngb = 11, name = TRUE, padValue = NA, array = TRUE) Error: Can not allocate vector vectors 1.7 GB Additionally: Warning message: 1: `rownames & lt; (`* Tmp *`, value = 1: 1879200): Access to total allocation of 8008 MB: see help (memory facility) Large datasets like FF and large memory are allowed but my dataset is allowed Can not initially be done. was made. I am using 64-bit R and 8 GB RAM. Is there a way to write the result of "getValuesFocal" in the file? I am grateful for any help for reading data using line
and
Nrows for example logic
library (raster) R & lt; - Raster (NR = 5, NC = 5, CRS = '+ ProZ = UTM + region = 12') R [] & lt; - 1: 25 as.matrix (r) getValuesFocal (r, line = 1, nrows = 2, ngb = 3, names = TRUE)
Comments
Post a Comment