On Thu, 24 May 2018 at 18:41 Mark R Payne <markpayneatw...@gmail.com> wrote:
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 can reproduce, with netcf-file-backed bricks. I would try obs.clim[[1]] + mdl.anom[[1]] or readAll(obs.clim) + readAll(mdl.anom) those differ mainly in what will happen to multi-layer versions of the files, the first will give just the first layer. The key is breaking the file-read-delay, both objects have no data in memory but the add operation invalidates and causes read to occur - but with a bug - (I will check in dev raster and report if necessary). FYI, R-Sig-Geo is generally a better forum for spatial stuff: https://stat.ethz.ch/mailman/listinfo/r-sig-geo Cheers, Mike. 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]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html <http://www.r-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. -- Dr. Michael Sumner Software and Database Engineer Australian Antarctic Division 203 Channel Highway Kingston Tasmania 7050 Australia [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.