| as_frame | R Documentation |
Converts an sf object (points or polygons) into the plain data frame that
travel_matrix() and select_units() expect: a column unit, the
coordinates lat/lon (centroids for polygons, in WGS 84) and, for
polygons, their area in square kilometres, next to the other columns of
the object. Nothing spatial is kept: use as_sf() to put the results back
on the geometries.
as_frame(x, unit = NULL)
x |
An |
unit |
Name of the column with the unit names; made from the row
numbers when |
A tibble with unit, lat, lon, area (polygons only) and the
attribute columns.
if (requireNamespace("sf", quietly = TRUE)) {
sq <- sf::st_sfc(sf::st_polygon(list(rbind(c(0, 0), c(0, 1), c(1, 1), c(1, 0), c(0, 0)))),
crs = 4326
)
cells <- sf::st_sf(crop = 3, geometry = sf::st_make_grid(sq, n = 3))
as_frame(cells)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.