Project

General

Profile

Calculating grid cell corners

Added by Anne Moree over 2 years ago

Hello,
I have data on a regular 0.5 degree lonlat grid, that is

dimensions:
y = 360 ;
x = 720 ;
variables:
double lat(y, x) ;
lat:_FillValue = NaN ;
lat:units = "degrees_north" ;
double lon(y, x) ;
lon:_FillValue = NaN ;
lon:units = "degrees_east" ;
double presence(y, x) ;
presence:_FillValue = NaN ;
presence:species = "Gadus morhua" ;
presence:coordinates = "lat lon" ;

The data are 1 or NaN and I would like to calculate the global sum of the area of the cells with value 1. However, cdo gridarea doesn't work because I do not have the grid cell corners.
Would CDO be able to construct the grid cell bounds/corners (and write them to a grid file?)? I could of course use the lon and lat to calculate all the grid cell areas myself, but I can imagine this is available in CDO somewhere which would save time :)

Thank you in advance for your help,

Anne


Replies (4)

RE: Calculating grid cell corners - Added by Karin Meier-Fleischer over 2 years ago

Hi Anne,

short answer: no. The data is on a curvilinear grid and you have to generate the bounds yourself. See https://code.mpimet.mpg.de/boards/2/topics/7701

Sorry,
Karin

RE: Calculating grid cell corners - Added by Anne Moree over 2 years ago

Dear Karin,

Thank you for your response! I think I understand that the fact that lon and lat are 2D makes it a curvilinear grid, right?
I made the datafile myself, so I now saved the data on a regular lonlat grid (attached).
The original data were just a csv of lon - lat - datavalue which I saved as a netcdf file (a lonlat grid would apply here I would expect).
Does that give us some new options?

Thank you for thinking along!

Anne

RE: Calculating grid cell corners - Added by Karin Meier-Fleischer over 2 years ago

The lonlat grid should work for gridarea without bounds (see link above).

RE: Calculating grid cell corners - Added by Anne Moree over 2 years ago

Dear Karin,

You are right - gridarea works for a regular lonlat grid without corer or bound data, great!

Thank you again,
Anne

    (1-4/4)