matlablatitude-longitudenetcdfareacdo-climate

How to calculate the area of each grid cell?


I have gridded data of air temperature with the spatial resolution 1.25 x 1.25 degrees (lon-lat). The data covers the Northern Hemisphere, and the first latitude is 90 degrees.

I need to calculate the area of each grid cell, and my approach is to do that from the latitude bands.

An alternative could be to read in the area of each grid cell directly from the netCDF file. Is that possible in MATLAB?

Here is my code I have tried; I am not sure if that is correct.

i=1:72;
j=2:73;
R=6371; % Earth's radius in km^2
deltalon=1.25; 
area=(pi/180)*R^2*((sind(latitude(i)) - sind(latitude(j)))*deltalon); % Area of each grid cell in km^2

Solution

  • If you don't mind a non-matlab solution, the easiest way to do this might be to simply use cdo from the command line:

    cdo gridarea yourdata.nc gridarea.nc 
    

    the netcdf file gridarea.nc will then contain the gridarea of each cell in m**2. The advantage of this is that cdo can handle a variety of grid projections, in addition to the standard regular lat-lon grid. You can then read this into your matlab programme.

    Apparently you can execute operating system commands from the MATLAB command line using the ! operator or the system function. (By the way, for R and python users, there are also dedicated "wrapper" packages that allow full cdo functionality without resorting to shell commands).

    Documentation of cdo is here: https://code.mpimet.mpg.de/projects/cdo/