Learn R Programming

sf (version 0.2-2)

crs: retrieve coordinate reference system from object

Description

retrieve coordinate reference system from sf or sfc object.

set or replace retrieve coordinate reference system from object

Usage

st_crs(x, ...)
"st_crs"(x, ...)
"st_crs"(x, ...)
st_crs(x) <- value
"st_crs"(x) <- value
"st_crs"(x) <- value

Arguments

x
object of class sf or sfc
...
ignored
value
one of (i) character: a valid proj4string (ii) integer, a valid epsg value (numeric), or (iii) a list containing named elements proj4string (character) and/or epsg (integer) with (i) and (ii).

Details

in case a coordinate reference system is replaced, no transformation takes place and a warning is raised to stress this. epsg values are either read from proj4strings that contain +init=epsg:... or set to 4326 in case the proj4string contains +proj=longlat and +datum=WGS84, literally

If both epsg and proj4string are provided, they are assumed to be consistent. In processing them, the epsg code, if not missing valued, is used and the proj4string is derived from it by a call to GDAL (which in turn will call PROJ.4). Warnings are raised when epsg is not consistent with a proj4string that is already present.

Examples

Run this code
 sfc = st_sfc(st_point(c(0,0)), st_point(c(1,1)))
 sf = st_sf(a = 1:2, geom = sfc)
 st_crs(sf) = 4326
 st_geometry(sf)
 sfc = st_sfc(st_point(c(0,0)), st_point(c(1,1)))
 st_crs(sfc) = 4326
 sfc

Run the code above in your browser using DataLab