xToCoords: Extract geographic coordinates from an object

View source: R/xToCoords.r

xToCoordsR Documentation

Extract geographic coordinates from an object

Description

This function extracts geographic coordinates from a data frame, matrix, or SpatialPoints* object

Usage

xToCoords(x, longLat = NULL, out = "default")

Arguments

x

A data.frame, matrix, SpatialPoints*, SpatVector, orsf object. If a data frame or matrix then the coordinate reference system is assumed to be unprojected (WGS84).

longLat

Two-element character vector or two-element integer vector. If x is a data frame then this should be a character list specifying the names of the fields in x or a two-element vector of integers that correspond to longitude and latitude (in that order). For example, c('long', 'lat') or c(1, 2). If x is a matrix then this is a two-element vector indicating the column numbers in x that represent longitude and latitude. For example, c(1, 2). If x is a SpatialPoints, SpatVector, or sf object then this is ignored.

out

Type of object to return. Options are:

  • 'default': Same type as input

  • 'sp': SpatialPoints object

  • 'vect': SpatVaector object

  • 'sf': sf object

Value

Object of classSpatialPoints, classSpatVector, classsf, a 2-column matrix, or a 2-column data.frame.


adamlilith/enmSdm documentation built on Jan. 6, 2023, 11 a.m.