我一直在尝试创建一个新的栅格对象,该对象仅包含现有栅格中的几个值。我正在使用此处找到的类栅格:https ://www.ga.gov.au/products/servlet/controller?event=FILE_SELECTION&catno=71071 。
class : RasterLayer dimensions : 14902, 19161, 285537222 (nrow, ncol, ncell)
resolution : 0.002349, 0.002349 (x, y)
extent : 110, 155.0092, -45.0048, -9.999999 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
values : G:\Spatial data\environmental_layers\Australian data\Land cover\Class\DLCDv1_Class.tif
min value : 1
max value : 34
我努力了:
pr <- rasterToPoints(r) # but the file is to big
和
s <- r[r>30 & r<33] # but the file is to big
和
rc <- reclass(r, c(-Inf,30,NA, 31,32, 1, 33,Inf,NA))
生成具有以下属性的栅格:
class : RasterLayer
dimensions : 14902, 19161, 285537222 (nrow, ncol, ncell)
resolution : 0.002349, 0.002349 (x, y)
extent : 110, 155.0092, -45.0048, -9.999999 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0
values : C:\Users\Adam\AppData\Local\Temp\R_raster_tmp\raster_tmp_61931056968.grd
min value : 1
max value : 33
我认为这会产生一个值为 NA 和 1 的栅格图层,但它有 33 个值。我一直在努力寻找一种在如此大的文件上使用 R 来“按属性提取”的方法。有人对我如何做到这一点有建议吗?