Skip to contents

The cell id of a longitude / latitude on a regular global grid

Usage

cell_id_of(lon, lat, nc = 7200L, nr = 3600L, deg = 0.05)

Arguments

lon, lat

numeric vectors (degrees).

nc, nr

integer; the grid's columns and rows (7200 x 3600).

deg

numeric; the cell size in degrees (0.05). nc * deg must be 360 and nr * deg 180.

Value

integer cell ids (row * nc + col + 1, row 0 at 90 N, col 0 at -180); a point at exactly 180 E or -90 S falls in the last column / row.