locs2sp: Convert matrix or dataframe with coordinates to a spatial...

Description Usage Arguments Value Examples

View source: R/locs2sp.R

Description

Convert matrix or dataframe with coordinates to a spatial object

Usage

1
locs2sp(locs, proj = "+init=epsg:4326", lon.col = NULL, lat.col = NULL)

Arguments

locs

A matrix or dataframe containing coordinates data. If a matrix, the first two columns will be assumed to contain longitude and latitude coordinates, respectively. If a dataframe, the function will try to guess the columns containing the coordinates based on column names.

proj

Character string specifying the projection (see proj4string or http://spatialreference.org). Default is geographic (unprojected) coordinates, datum WGS84.

lon.col

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

lat.col

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

Value

A SpatialPoints or SpatialPointsDataFrame.

Examples

1
2
3
4
5
locs <- matrix(runif(20), ncol = 2)
locs.sp <- locs2sp(locs)

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

Pakillo/rSDM documentation built on Oct. 15, 2020, 3:20 a.m.