locs2sf | R Documentation |
Convert matrix or data frame with point coordinates to a spatial (sf) object
locs2sf(locs, crs = 4326, lon.col = NULL, lat.col = NULL)
locs |
A matrix or data frame containing point coordinates data.
If a matrix, the first two columns will be assumed to contain longitude
and latitude coordinates, respectively.
If a data frame, the function will try to guess the columns containing the coordinates
based on column names, unless |
crs |
A character string, number (EPSG value), or |
lon.col |
Character (optional). Name of the column containing longitude data. |
lat.col |
Character (optional). Name of the column containing latitude data. |
An sf::sf()
object.
locs <- matrix(runif(20), ncol = 2)
locs2sf(locs)
locs <- data.frame(species = rep("Laurus nobilis", 10), x = runif(10), y = runif(10))
locs2sf(locs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.