[R-sig-Geo] Problem with raster
Mark Payne
markpayneatwork at gmail.com
Fri Feb 21 15:59:17 CET 2014
Hi,
I am having a problem with the following code - I'm trying to create a
raster from a SpatialGrid, but there seems to be something going wrong
along the way - the problem pops up when I try to build two
rasterlayers into a brick:
> halfrect.grd <- GridTopology(c(-22.75,36.75),
+ c(0.5,0.5),
+ c(46,55))
> grd.sp <- SpatialGrid(halfrect.grd,proj4string=CRS("+longlat"))
> grd.r <- raster(grd.sp)
> brick(grd.r,grd.r)
class : RasterBrick
dimensions : 55, 46, 2530, 1 (nrow, ncol, ncell, nlayers)
resolution : 0.5, 0.5 (x, y)
extent : -23, 0, 36.5, 64 (xmin, xmax, ymin, ymax)
coord. ref. : +longlat
This works ok so far. But then if I try to change the value, it fails
> EP.r <- grd.r
> EP.r[] <- NA
> brick(EP.r,EP.r) #Doesn't
Error in x[, 2] : subscript out of bounds
> values(EP.r) <- NA
> brick(EP.r,EP.r) #Doesn't
Error in x[, 2] : subscript out of bounds
>
My package details are below. Does anyone have any ideas what could be
going wrong?
Mark
> packageDescription("raster")
Package: raster
Type: Package
Title: raster: Geographic data analysis and modeling
Version: 2.2-12
Date: 2014-1-17
<snip>
> R.version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
>
More information about the R-sig-Geo
mailing list