[R] Problem with adding a raster and a brick

Mark R Payne m@rkp@yne@twork @ending from gm@il@com
Thu May 24 10:40:44 CEST 2018


Hi,

I seem to be having a problem adding the following two raster objects
together - one is a rasterLayer, the other is a rasterBrick. The extent,
resolution, and origin are the same, so according to my understand it
should work. The objects look like so:

> obs.clim
class       : RasterLayer
dimensions  : 60, 200, 12000  (nrow, ncol, ncell)
resolution  : 0.5, 0.5  (x, y)
extent      : -70, 30, 50, 80  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source :
/home/mpayne/Documents/Predictability_engine/scratch/Bluefin/HadISST/
obs_climatology.nc
names       : sst
z-value     : 1988-02-15
zvar        : sst

> mdl.anom
class       : RasterBrick
dimensions  : 60, 200, 12000, 1  (nrow, ncol, ncell, nlayers)
resolution  : 0.5, 0.5  (x, y)
extent      : -70, 30, 50, 80  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source :
/home/mpayne/Documents/Predictability_engine/scratch/Bluefin/DCPP-hindcasts/IPSL-CM5A-LR/B.realmean/IPSL-CM5A-LR_S19610101_L000000_realmean_anom.nc

names       : X1961.08.16
Date        : 1961-08-16
varname     : tos

When I try to add them together, I get the follow error:

>       mdl.val <- obs.clim + mdl.anom
Error in .readRowsNetCDF(x = x, row = row, nrows = nrows, col = col, ncols
= ncols) :
  no slot of name "band" for this object of class ".MultipleRasterData"
>

I get the same error if I treat mdl.anom as a raster, or if they are both
bricks. Any suggestions what could be going wrong? Installation details
below

Best wishes,

Mark

> R.version
               _
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          4.2
year           2017
month          09
day            28
svn rev        73368
language       R
version.string R version 3.4.2 (2017-09-28)
nickname       Short Summer
>
> packageDescription("raster")
Package: raster
Type: Package
Title: Geographic Data Analysis and Modeling
Version: 2.6-7
Date: 2017-11-12

> packageDescription("ncdf4")
Package: ncdf4
Version: 1.16
Date: 2017-04-01

	[[alternative HTML version deleted]]



More information about the R-help mailing list