project_table: Transform locations in a table from one projection to another

View source: R/table.R

project_tableR Documentation

Transform locations in a table from one projection to another

Description

Elements of the input that are NA are returned as NA

Usage

project_table(
  x = data.frame(lon = c(-72, -63), lat = c(39, 46)),
  from_crs = ifelse(use_wkt("sf"), "epsg:4326",
    "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"),
  to_crs = ifelse(use_wkt("sf"), "epsg:32619", "+proj=utm +zone=19 ellps=WGS84"),
  from_names = c("lon", "lat"),
  to_names = c("x", "y")
)

Arguments

x

table(data.frame or tibble) with columns specified by from_names

from_crs

projection of the source coordinates - see st_crs

to_crs

projection of the source coordinates - see st_crs

from_names

string, the names of the x and y coords to project from, ['lon', 'lat'] default.

to_names

string, the names of the x and y coords to project into, ['x', 'y'] default. If from_names is the same as to_names then replacement occurs, otherwise two new columns to_names are appended to the table.

Value

updated table

Examples

## Not run: 
x <- data.frame(lon = c(-72, -63), lat = c(39, 46))
(y <- project_table(x, to_names = c("false_easting", "false_northing")))
# lon lat false_easting false_northing
# 1 -72  39      240199.8        4321059
# 2 -63  46      964564.1        5111577

## End(Not run)

BigelowLab/rasf documentation built on July 18, 2022, 10:19 p.m.