Skip to contents

Coordinates consistently use longitude before latitude. Named data-frame columns and sf POINT objects are preferred for clarity.

Usage

point_to_cell(points, resolution = NULL, grid = hex_grid())

Arguments

points

Point coordinates as c(lon, lat), a two-column matrix/data frame, or an sf POINT object.

resolution

Target resolution. Required for modern grids; fixed by a legacy_grid().

grid

A grid definition from hex_grid() or legacy_grid().

Value

A globalhex_cell vector with one cell per input point.

Examples

grid <- hex_grid()
point_to_cell(c(-73.9857, 40.7484), resolution = 5, grid = grid)
#> <globalhex_cell[1]>
#> [1] 0203124