| lonlat_to_cell | R Documentation |
Converts geographic coordinates to DGGS cell IDs using a grid specification.
lonlat_to_cell(lon, lat, grid)
lon |
Numeric vector of longitudes in degrees |
lat |
Numeric vector of latitudes in degrees |
grid |
A HexGridInfo or HexData object, or legacy hexify_grid |
This function accepts either a HexGridInfo object from hex_grid() or
a HexData object from hexify(). If a HexData object is provided,
its grid specification is extracted automatically.
Numeric vector of cell IDs
cell_to_lonlat for the inverse operation,
hex_grid for creating grid specifications
grid <- hex_grid(area_km2 = 1000)
cells <- lonlat_to_cell(lon = c(0, 10), lat = c(45, 50), grid = grid)
# Or use HexData object
df <- data.frame(lon = c(0, 10, 20), lat = c(45, 50, 55))
result <- hexify(df, lon = "lon", lat = "lat", area_km2 = 1000)
cells <- lonlat_to_cell(lon = 5, lat = 48, grid = result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.