PRO LATLON_TO_GRIDINDEX, LAT, LON, RES, INDEX ; For an equal angle earth grid spanning the range -180 to +180 in longitude ; and -90 to +90 in latitude, compute the zero-based 1D grid cell index corresponding ; to a given latitude, longitude, and grid resolution (all in degrees). ; ; The origin of the grid is at -180W, -90S. ; ; For a grid with 10 degree resolution, there are 648 grid cells covering the ; Earth (18 rows and 36 columns). Grid cell index 0 is at lower left of the ; global grid, and grid cell index 647 is at the upper right. ;- Get number of columns in the grid numcol = floor(360.0 / res) ;- Compute row and column in the grid (zero-based) row = floor((lat + 90.0) / res) col = floor((lon + 180.0) / res) ;- Compute grid index (zero-based) index = numcol * row + col END