Learn R Programming

lwgeom (version 0.1-0)

st_transform_proj: Transform or convert coordinates of simple features directly with Proj.4

Description

Transform or convert coordinates of simple features directly with Proj.4

Usage

st_transform_proj(x, crs, ...)

# S3 method for sfc st_transform_proj(x, crs, ...)

# S3 method for sf st_transform_proj(x, crs, ...)

# S3 method for sfg st_transform_proj(x, crs, ...)

Arguments

x

object of class sf, sfc or sfg

crs

character; proj4string of target coordinate reference system

...

ignored

Details

Transforms coordinates of object to new projection, using Proj.4 and not the GDAL API.

The st_transform_proj method for sfg objects assumes that the CRS of the object is available as an attribute of that name.

Examples

Run this code
# NOT RUN {
library(sf)
p1 = st_point(c(7,52))
p2 = st_point(c(-30,20))
sfc = st_sfc(p1, p2, crs = 4326)
sfc
st_transform_proj(sfc, "+proj=wintri")
library(sf)
nc = st_read(system.file("shape/nc.shp", package="sf"))
st_transform_proj(nc[1,], "+proj=wintri +over")
st_transform_proj(structure(p1, proj4string = "+init=epsg:4326"), "+init=epsg:3857")
# }

Run the code above in your browser using DataLab