This function creates a simple feature POINT geometry column from x and y
columns in a data frame. The resulting object is a sf geometry set that can
be used as an additional spatial column in an sf data frame, in addition to
the primary geometry column.
Usage
sf_point_col(x, y, crs = sf::NA_crs_)Examples
sf_point_col(
x = show_meta(example_tt)$nest_lon,
y = show_meta(example_tt)$nest_lat,
crs = 4326
)
#> Geometry set for 3 features
#> Geometry type: POINT
#> Dimension: XY
#> Bounding box: xmin: -2.44 ymin: -1.76 xmax: 1.37 ymax: 0.43
#> Geodetic CRS: WGS 84
#> POINT (1.37 0.06)
#> POINT (-2.44 -1.76)
#> POINT (-0.78 0.43)
# assign to a column in the meta with mutate
library(dplyr)
show_meta(example_tt) %>%
mutate(nest_coord = sf_point_col(
x = show_meta(example_tt)$nest_lon,
y = show_meta(example_tt)$nest_lat,
crs = 4326
))
#> track_id sex nest_lon nest_lat nest_coord
#> 1 a male 1.37 0.06 POINT (1.37 0.06)
#> 2 b male -2.44 -1.76 POINT (-2.44 -1.76)
#> 3 c female -0.78 0.43 POINT (-0.78 0.43)