将 rasterbrick 从内存保存到磁盘

saving rasterbrick from memory to disk

我有一个使用 dismo R 包生成的光栅砖:

biovars(prec,tmax,tmin)
#> class       : RasterBrick 
#> dimensions  : 621, 1405, 872505, 19  (nrow, ncol, ncell, nlayers)
#> resolution  : 0.04166667, 0.04166667  (x, y)
#> extent      : -125.0208, -66.47917, 24.0625, 49.9375  (xmin, xmax, ymin, ymax)
#> coord. ref. : NA 
#> data source : in memory
#> names       :          bio1,          bio2,          bio3,          bio4,          #> bio5,          bio6,          bio7,          bio8,          bio9,         #> bio10,         bio11,         bio12,         bio13,         bio14,         bio15, ... 
#> min values  :     -5.877542,    -22.975250,            -?,    128.791868,     #> -4.569000,    -13.221000,     -6.819000,    -11.703167,    -15.058666,      1.778000,    -15.058666,     31.000000,      6.000000,      0.000000,      4.860504, ... 
#> max values  :  2.546279e+01, -2.974167e+00,  1.828863e+06,  1.357540e+03,  3.081900e+01,  2.528200e+01,  2.591300e+01,  3.418683e+01,  3.568500e+01,  3.697417e+01,  2.146250e+01,  6.317000e+03,  1.146000e+03,  1.440000e+02,  1.295139e+02, ... 

我想将 rasterbrick 中包含的 19 个图层保存为单独的 .asc 文件。

我试过了 writeRaster(brick, filename="bio.asc", format="ascii", bylayer=TRUE),但最终出现以下错误:

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘writeRaster’ for signature ‘"standardGeneric", "character"’

我可能错了,但从错误消息来看,在我看来你传递了一个错误的变量给 writeraster(即,不是光栅、光栅堆栈或光栅砖)