sp_transform: Transform coordinates

View source: R/spatial.R

sp_transformR Documentation

Transform coordinates

Description

For transformations involving NAD27 coordinates ("+datum=NAD27"), custom parameters for Alaska (excluding Aleutian islands) are automatically applied ("+towgs84=-5,135,172"). See http://web.archive.org/web/20130905025856/http://surveying.wb.psu.edu/sur351/DatumTrans/datum_transformations.htm.

Usage

sp_transform(xy, from, to, cols = 1:2)

Arguments

xy

Data.frame or numeric vector (coerced to single-row data.frame).

from

Current proj.4 string.

to

Target proj.4 string.

cols

Column numbers or names specifying which xy columns are x and y coordinates.

Value

Object of the same class and dimensions as xy with coordinates transformed in place.

Examples

xy <- c(-147.25079, 61.18586, 505)
sp_transform(xy, "+proj=longlat +datum=WGS84", "+proj=utm +zone=6")
xy <- c(x = -147.25079, y = 61.18586, z = 505)
sp_transform(xy, "+proj=longlat +datum=WGS84", "+proj=utm +zone=6")
xy <- data.frame(z = 505, x = -147.25079, y = 61.18586)
sp_transform(xy, "+proj=longlat +datum=WGS84", "+proj=utm +zone=6", cols = c("x", "y"))
xy <- data.frame(x = c(NA, -147.25079), y = c(NA, 61.18586), z = 505)
sp_transform(xy, "+proj=longlat +datum=WGS84", "+proj=utm +zone=6")

columbia-glacier/cgr documentation built on Jan. 17, 2024, 2:42 p.m.