我正在学习R tool
并且我跟着一个例子但是尽管我做了一切相同的事情,但在the plot raster
期间我遇到了错误。
这是代码:
library(raster)
library(rgdal)
myRaster1 <- raster(nrow=4, ncol=4)
myRaster1[]<- 1:ncell(myRaster1)
myRaster2=raster(nrow=8, ncol=8)
resample(myRaster1, myRaster2, method='bilinear')
plot(myRaster2, main="Raster with 32 pixels")
这是错误警告:
Error in .plotraster2(x, col = col, maxpixels = maxpixels, add = add, :
no values associated with this RasterLayer
怎样才能解决这个问题?
答案 0 :(得分:1)
您需要为重新采样的栅格命名:
library(raster)
library(rgdal)
myRaster1 <- raster(nrow=4, ncol=4)
myRaster1[]<- 1:ncell(myRaster1)
myRaster2=raster(nrow=8, ncol=8)
myRaster1.resampled <- resample(myRaster1, myRaster2, method='bilinear')
plot(myRaster1.resampled, main="Raster with 32 pixels")