An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120110/d8636f68/attachment.pl>
rotate-ing a raster brick?
3 messages · Hartley, Andrew, Robert J. Hijmans, Andy Hartley
1 day later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20120111/d7419639/attachment.pl>
Hi Robert, Thanks for replying. Unfortunately I can't change my version of R (we have a centrally installed version that gets rolled out every so often). I think raster is up to date though. Here's the info you asked for - the traceback doesn't make much sense to me! I've already done a work around (looping through each band, and stacking at the end), but it would be nice to understand why this is happening. Cheers, Andy
sessionInfo()
R version 2.13.1 (2011-07-08) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] ncdf_1.6.6 raster_1.9-52 sp_0.9-93 loaded via a namespace (and not attached): [1] grid_2.13.1 lattice_0.19-30 tools_2.13.1
rbb <- rotate(rb)
Error in rowSums(is.na(x)) : 'x' must be an array of at least two dimensions
traceback()
10: stop("'x' must be an array of at least two dimensions")
9: rowSums(is.na(x))
8: .local(x, y, ...)
7: merge(x, tolerance = tolerance, filename = filename, format = format,
datatype = datatype, overwrite = overwrite, progress = progress,
ext = ext, overlap = overlap, check = FALSE)
6: merge(x, tolerance = tolerance, filename = filename, format = format,
datatype = datatype, overwrite = overwrite, progress = progress,
ext = ext, overlap = overlap, check = FALSE)
5: .local(x, y, ...)
4: merge(r1, r2, ...)
3: merge(r1, r2, ...)
2: rotate(rb)
1: rotate(rb)
Andrew Hartley Climate Impacts Risk Analyst Met Office FitzRoy Road Exeter EX1 3PB United Kingdom Tel: +44 (0)1392 885720 Fax: +44 (0)1392 885681 E-mail: andrew.hartley at metoffice.gov.uk http://www.metoffice.gov.uk <blocked::http://www.metoffice.gov.uk/> Join us in celebrating 150 years of forecasting for the nation and enter our photo competition http://www.metoffice.gov.uk/about-us/who/our-history <blocked::http://www.metoffice.gov.uk/about-us/who/our-history> ________________________________ From: Robert Hijmans [via R-sig-geo] [mailto:ml-node+s2731867n7179261h67 at n2.nabble.com] Sent: 12 January 2012 09:18 To: Hartley, Andrew Subject: Re: rotate-ing a raster brick? Andrew, Strange, the same thing (for the same file) works for me. Could you send your sessionInfo() and a traceback() after the error occurs ( that should reveal where the call to rowSums(is.na(x)) occurs (I have no idea) that the error message complains about ) Robert On Tue, Jan 10, 2012 at 4:32 AM, Hartley, Andrew < [hidden email]> wrote: > Hi list, > > First, a big thank you to the people behind the development of the > "raster" package - I find it very useful, especially with the addition > of the Z dimension. Now, a question - I've imported climate data into R > from the CMIP5 project. All the data is in NetCDF format, which is much > easier to handle now (big thanks for that!). I find the 'rotate' > function especially useful because most of these datasets seem to be > between 0 and 360 degrees. > > I've used rotate successfully on one band of the imported data, but it > throws up an error with bricks or stacks. See the code below. Is this a > known error, or am I doing something wrong? > > Cheers, > Andy > > Example file downloaded from > http://pcmdi3.llnl.gov/esgcet/dataset/cmip5.output1.CCCma.CanESM2.esmHis > torical.mon.atmos.Amon.r1i1p1.html > > f="CMIP5/CCCma/CanESM2/historical/mon/atmos/Amon/r1i1p1/v20111028/pr/pr_ > Amon_CanESM2_historical_r1i1p1_185001-200512.nc" > > rb <- brick(f, crs="+proj=longlat +datum=WGS84") > rb > class : RasterBrick > dimensions : 64, 128, 8192, 1872 (nrow, ncol, ncell, nlayers) > resolution : 2.8125, 2.789327 (x, y) > extent : -1.40625, 358.5938, -89.25846, 89.25846 (xmin, xmax, > ymin, ymax) > coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 > values : /media/WD > MYBOOK/CMIP5/CCCma/CanESM2/historical/mon/atmos/Amon/r1i1p1/v20111028/pr > /pr_Amon_CanESM2_historical_r1i1p1_185001-200512.nc > zvar : pr > rbr <- rotate(rb) > Error in rowSums(is.na(x)) : > 'x' must be an array of at least two dimensions > > r <- subset(rb, 1) > rr <- rotate(r) > rr > class : RasterLayer > dimensions : 64, 128, 8192 (nrow, ncol, ncell) > resolution : 2.8125, 2.789327 (x, y) > extent : -181.4062, 178.5938, -89.25846, 89.25846 (xmin, xmax, > ymin, ymax) > coord. ref. : NA > values : in memory > min value : 0 > max value : 0.0003839434 > -- > Andrew Hartley Climate Impacts Risk Analyst > Met Office FitzRoy Road Exeter EX1 3PB United Kingdom > Tel: +44 (0)1392 885720 Fax: +44 (0)1392 885681 > E-mail: [hidden email] http://www.metoffice.gov.uk > <blocked::http://www.metoffice.gov.uk/> > > Join us in celebrating 150 years of forecasting for the nation and enter > our photo competition > http://www.metoffice.gov.uk/about-us/who/our-history > <blocked::http://www.metoffice.gov.uk/about-us/who/our-history> > > > [[alternative HTML version deleted]] > > _______________________________________________ > R-sig-Geo mailing list > [hidden email] > https://stat.ethz.ch/mailman/listinfo/r-sig-geo > [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list [hidden email] https://stat.ethz.ch/mailman/listinfo/r-sig-geo ________________________________ If you reply to this email, your message will be added to the discussion below: http://r-sig-geo.2731867.n2.nabble.com/rotate-ing-a-raster-brick-tp71718 58p7179261.html To start a new topic under R-sig-geo, email ml-node+s2731867n2731867h53 at n2.nabble.com To unsubscribe from R-sig-geo, click here <http://r-sig-geo.2731867.n2.nabble.com/template/NamlServlet.jtp?macro=u nsubscribe_by_code&node=2731867&code=YW5kcmV3LmhhcnRsZXlAbWV0b2ZmaWNlLmd vdi51a3wyNzMxODY3fC0xNTc1OTEyMTQw> . NAML <http://r-sig-geo.2731867.n2.nabble.com/template/NamlServlet.jtp?macro=m acro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.names paces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.nam l.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nab ble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamesp ace-nabble.view.web.template.InstantMailNamespace&breadcrumbs=instant+em ails%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_ins tant_email%21nabble%3Aemail.naml> -- View this message in context: http://r-sig-geo.2731867.n2.nabble.com/rotate-ing-a-raster-brick-tp7171858p7179691.html Sent from the R-sig-geo mailing list archive at Nabble.com.