locs2vect: Convert matrix or data frame with point coordinates to a...

View source: R/locs2vect.R

locs2vectR Documentation

Convert matrix or data frame with point coordinates to a SpatVector object

Description

Convert matrix or data frame with point coordinates to a SpatVector object

Usage

locs2vect(locs, crs = 4326, lon.col = NULL, lat.col = NULL)

Arguments

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 lon.col and lat.col are provided.

crs

A number specifying the EPSG code (see https://spatialreference.org). Default is geographic (unprojected) coordinates, datum WGS84 (EPSG = 4326).

lon.col

Character (optional). Name of the column containing longitude data.

lat.col

Character (optional). Name of the column containing latitude data.

Value

A terra::SpatVector() object.

Examples

locs <- matrix(runif(20), ncol = 2)
locs2vect(locs)

locs <- data.frame(species = rep("Laurus nobilis", 10), x = runif(10), y = runif(10))
locs2vect(locs)

Pakillo/rSDM documentation built on March 1, 2025, 12:30 a.m.