Convert matrix or dataframe with coordinates to a spatial object
locs2sp(locs, proj = "+init=epsg:4326", lon.col = NULL, lat.col = NULL)
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 |
lon.col | Character (optional). Name of the column containing longitude data. |
lat.col | Character (optional). Name of the column containing latitude data. |
A SpatialPoints or SpatialPointsDataFrame.
#>locs <- data.frame(species = rep("Laurus nobilis", 10), x = runif(10), y = runif(10)) locs.sp <- locs2sp(locs)#>#>