get_coords: Add coordinates to the data slot of a SpatialPointsDataFrame

View source: R/balance_check.R

get_coordsR Documentation

Add coordinates to the data slot of a SpatialPointsDataFrame

Description

Add coordinates to the data slot of a SpatialPointsDataFrame

Usage

get_coords(
  points,
  x_var = "XMETERS",
  y_var = "YMETERS",
  projection =
    "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs"
)

Arguments

points

A point sf object. The coordinates will be extracted for these points. Note: a multipoint sf object will not work.

x_var

Character string. The name of the variable to add the x component of the coordinates to in points@data. If the variable already exists, it will be overwritten. Defaults to "XMETERS".

y_var

Character string. The name of the variable to add the y component of the coordinates to in points@data. If the variable already exists, it will be overwritten. Defaults to "YMETERS".

projection

Character string. The projection to use when determining the coordinates. Defaults to "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs", Albers equal area.

Value

The sf object provided as points with the coordinates added to the variables defined with x_var and y_var.


Landscape-Data-Commons/sample.design documentation built on March 20, 2023, 8:58 p.m.