transform_crs: Transform between Coordinate Reference Systems

View source: R/transform-projection.R

transform_crsR Documentation

Transform between Coordinate Reference Systems

Description

Transform between Coordinate Reference Systems

Usage

transform_crs(data, coord, in_crs, out_crs, append = TRUE)

transform_LV95_to_WSG84(data, coord = c(lon = "x", lat = "y"), append = TRUE)

transform_WSG84_to_LV95(data, coord = c(x = "lon", y = "lat"), append = TRUE)

transform_LV03_to_WSG84(data, coord = c(lon = "x", lat = "y"), append = TRUE)

transform_WSG84_to_LV03(data, coord = c(x = "lon", y = "lat"), append = TRUE)

Arguments

data

input data

coord

mappping of columns for Conversion

in_crs

source coordinate reference system as sp::CRS

out_crs

target coordinate reference system as sp::CRS

append

append data in new Columns

Value

tibble with transformed coordinates

WSG84 (EPSG 4326) vs Web Pseudo Mercator (EPSG 3857)

See Tiles à la Google Maps for a detailed explanation. In Short:

EPSG:4326 uses a coordinate system on the surface of a sphere or ellipsoid of reference.

EPSG:3857 uses a coordinate system PROJECTED from the surface of the sphere or ellipsoid to a flat surface.

Usually Packages and Webservices expects coordinates for Elements in EPSG:4326, one Exception is leaflet::addRasterImage()

Known Issues

R spatial is migrating to PROJ6+ and gdal3+. At the moment the sp::spTransform isn't converted to use the WKT comments, and rgdal raises some Warnings. The transformation are done correctly.

See Also

Examples

fn <- system.file("extdata", "meta_smn.rds", package = "rOstluft.data")
data <- readRDS(fn)
data <- dplyr::distinct(data, site, x, y)
transform_crs(
  data = data,
  coord = c(lon = "x", lat = "y"),
  in_crs = sf::st_crs("EPSG:2056"),
  out_crs = sf::st_crs("EPSG:4326")
)

transform_crs(
  data = data,
  coord = c(lon = "x", lat = "y"),
  in_crs = sf::st_crs("EPSG:2056"),
  out_crs = sf::st_crs("EPSG:4326"),
  append = FALSE
)

transform_LV95_to_WSG84(data)


Ostluft/rOstluft documentation built on Feb. 6, 2024, 1:26 a.m.