Skip to contents

This function assigns a set of geographic coordinates (longitude and latitude) to grid cells based on a specified cell size.

Usage

assign_coords_to_grid(coords, cell_size)

Arguments

coords

A data frame or matrix with two columns: longitude and latitude.

cell_size

Numeric value representing the size of each grid cell, typically in degrees.

Value

A character vector of grid cell identifiers, where each identifier is formatted as "x_y", representing the grid cell coordinates.

Examples

coords <- data.frame(long = c(-122.4194, 0), lat = c(37.7749, 0))
cell_size <- 1
assign_coords_to_grid(coords, cell_size)
#> [1] "0_37"  "122_0"