gt_add_sf
adds an active sf geometry column to a gen_tibble
object. The
resulting gen_tbl
inherits from sf
and can be used with functions from
the sf
package. It is possible to either create a sf::sfc
geometry
column from coordinates, or to provide an existing geometry column (which
will then become the active geometry for sf
).
Arguments
- x
a
gen_tibble
object- coords
a vector of length 2, giving the names of the x and y columns in
x
(i.e. the coordinates, e.g. longitude and latitude). Ifcoords
is not provided, the geometry column must be provided.- crs
the coordinate reference system of the coordinates. If this is not set, it will be set to the default value of
sf::st_crs(4326)
.- sfc_column
the name of an
sf::sfc
column to be used as the geometry
Value
a gen_tibble
object with an additional geometry column (and thus
belonging also to sf
class).