l m learning R tool
and l followed an example but although l did everything same ,l got an error during the plot raster
.
here is the code:
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")
here is the error warnings:
Error in .plotraster2(x, col = col, maxpixels = maxpixels, add = add, :
no values associated with this RasterLayer
how can l solve this problem?
You need to give a name to your resampled Raster:
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")