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?
Answer
This is how you can do that with R/raster
library(raster)
r <- raster() # by default 1 by 1 degree, just what you want
a <- area(r)
Each cell of RasterLayer 'a' has a value representing its approximate area
To illustrate the results for one column (it is the same for all columns), as area varies by latitude, not by longitude
lat <- yFromRow(r, 1:nrow(r))
area <- a[,1]
plot(lat, area)
No comments:
Post a Comment