| as_sf | R Documentation |
Converts a HexData object to an sf spatial features object. Can create either point geometries (cell centers) or polygon geometries (cell boundaries).
as_sf(x, geometry = c("point", "polygon"), ...)
x |
A HexData object |
geometry |
Type of geometry: "point" (default) or "polygon" |
... |
Additional arguments (ignored) |
For point geometry, cell centers (cell_cen_lon, cell_cen_lat) are used. For polygon geometry, cell boundaries are computed using the grid specification.
An sf object
df <- data.frame(lon = c(0, 10, 20), lat = c(45, 50, 55))
result <- hexify(df, lon = "lon", lat = "lat", area_km2 = 1000)
# Get sf points
sf_pts <- as_sf(result)
# Get sf polygons
sf_poly <- as_sf(result, geometry = "polygon")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.