locs_from_sf() converts sf point features into the data frame shape
expected by popmaps(), tune_popmaps(), and
compare_popmaps_surfaces(). The returned table has site, longitude,
latitude, and ancestry coefficient columns.
Usage
locs_from_sf(
x,
ancestry_cols = NULL,
site_col = NULL,
crs = "EPSG:4326",
coord_names = c("lon", "lat")
)Arguments
- x
An
sfobject with point geometries.- ancestry_cols
Ancestry coefficient columns, supplied as names or integer positions. If
NULL, all numeric non-geometry columns exceptsite_colare used.- site_col
Optional site identifier column, supplied as a name or integer position. If
NULL, a column namedsite,sample,id,name, orpopulationis used when present; otherwise synthetic site names are created.- crs
CRS to transform the coordinates to before extracting x/y values. The default is
"EPSG:4326"for longitude/latitude output. Setcrs = NULLto keep the input CRS.- coord_names
Names for the returned coordinate columns.
Examples
if (requireNamespace("sf", quietly = TRUE)) {
locs <- locs_from_sf(sf::st_as_sf(
data.frame(site = "a", axis1 = 1, axis2 = 0, lon = -110, lat = 39),
coords = c("lon", "lat"),
crs = 4326
))
}