I have a simple array (not geo-referenced in any way) in Matlab (which is not a language I know a huge amount about...so I can export it to other languages if needed) which has the dimensions 180 x 360 and contains data for each 1 x 1 degree area of the globe. I need to calculate the area of certain cells in this raster.
Obviously the area will vary based on longitude, but I have no idea how to calculate this area, particularly as my array is not georeferenced. I saw a reference online to the area function in the R raster package, but I'm not sure how to get my matlab data into a Raster object within R.
Does anyone have any suggestions as to how best to calculate these areas?
areadoes not appear to be a matrix. On my system (R.2.11.1) I have to usearea <- a[seq(from=1, by=360, length.out=180)]to extract one value per row. On the average,areaoverestimates the cell area by 0.2%. – whuber Jul 20 '12 at 12:58ais a RasterLayer. You can dom <- as.matrix(a)to get a matrix. I'll try your formula instead. You are using a very old version of R. It would be more useful to report the version of raster. – Robert Hijmans Jul 22 '12 at 00:26