st_crs

0th

Percentile

Retrieve coordinate reference system from object

Retrieve coordinate reference system from sf or sfc object

Set or replace retrieve coordinate reference system from object

Keywords
datasets
Usage
NA_crs_
st_crs(x, ...)
\method{st_crs}{sf}(x, ...)
\method{st_crs}{numeric}(x, ...)
\method{st_crs}{character}(x, ...)
\method{st_crs}{sfc}(x, ...)
st_crs(x) <- value
\method{st_crs}{sf}(x) <- value
\method{st_crs}{sfc}(x) <- value
st_set_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

NA_crs_ is the crs object with missing values for epsg and proj4string.

the *crs functions get, set or replace the crs attribute of a simple feature geometry list-column. This attribute is of class crs, and is a list consisting of epsg (integer epsg code) and proj4string (character). Two objects of class crs are semantically identical when: (1) they are completely identical, or (2) they have identical proj4string but one of them has a missing epsg ID. As a consequence, equivalent but different proj4strings, e.g. "+proj=longlat +datum=WGS84" and "+datum=WGS84 +proj=longlat" , are considered different. The operators == and != are overloaded for crs objects to establish semantical identity.

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.

Value

object of class crs, which is a list with elements epsg (length-1 integer) and proj4string (length-1 character).

Format

An object of class crs of length 2.

Aliases
  • NA_crs_
  • st_crs
  • st_crs.character
  • st_crs.numeric
  • st_crs.sf
  • st_crs.sfc
  • st_crs<-
  • st_crs<-.sf
  • st_crs<-.sfc
  • st_set_crs
Examples
 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
sfc = st_sfc(st_point(c(0,0)), st_point(c(1,1)))
library(dplyr)
x <- sfc %>% st_set_crs(4326) %>% st_transform(3857)
x
Documentation reproduced from package sf, version 0.2-4, License: GPL-2 | MIT + file LICENSE

Community examples

Looks like there are no examples yet.