[R-sig-Geo] Memory issues using raster::subs

Wall, Wade A ERDC-RDE-CERL-IL CIV W@de@A@W@ll @ending from erdc@dren@mil
Mon Jul 9 15:44:41 CEST 2018


Hi all,

I am having issues with using the subs function in the raster package. In the past, I have successfully used the function to reclassify a raster, but now when I try to use it, I am receiving the error " Error: cannot allocate vector of size 2.0 Gb". The code is the same as what I had used before with a larger raster and data.frame. 

For example, this code works:

segments = raster(D:/path/To/InputRaster.tif) ### objects raster
obj_predicted = data.frame(zone,predicted)
filename="D:/path/To/Raster.tif"
subs(segments,obj_predicted,by=1,which=2,filename=filename,progress="text")

The segments raster is of size 71026 by 78701. obj_predicted is a 1,693,839 X 2 column data frame, with each row of the first column of the data frame corresponding to a pixel value in the segments raster. 

However, when I replace the segments raster with another raster that is 14157 by 11923  and the obj_predicted data frame is 6588 x 2, I receive the error message. The crs of both rasters is the same, both data frames are essentially the same etc. 

Sorry that I can't really provide the data to attempt reproduction. Any help would be appreciated. I am going to attempt to process by block, but this seems 

Wade



More information about the R-sig-Geo mailing list