EVOLUTION-MANAGER
Edit File: st_crs.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Retrieve coordinate reference system from object</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for st_crs {sf}"><tr><td>st_crs {sf}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Retrieve coordinate reference system from object</h2> <h3>Description</h3> <p>Retrieve coordinate reference system from sf or sfc object </p> <p>Set or replace retrieve coordinate reference system from object </p> <h3>Usage</h3> <pre> st_crs(x, ...) ## S3 method for class 'sf' st_crs(x, ...) ## S3 method for class 'numeric' st_crs(x, ...) ## S3 method for class 'character' st_crs(x, ...) ## S3 method for class 'sfc' st_crs(x, ..., parameters = FALSE) ## S3 method for class 'bbox' st_crs(x, ...) ## S3 method for class 'CRS' st_crs(x, ...) ## S3 method for class 'crs' st_crs(x, ...) st_crs(x) <- value ## S3 replacement method for class 'sf' st_crs(x) <- value ## S3 replacement method for class 'sfc' st_crs(x) <- value st_set_crs(x, value) NA_crs_ ## S3 method for class 'crs' is.na(x) ## S3 method for class 'crs' x$name ## S3 method for class 'crs' format(x, ...) st_axis_order(authority_compliant = logical(0)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>numeric, character, or object of class <a href="sf.html">sf</a> or <a href="sfc.html">sfc</a></p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>ignored</p> </td></tr> <tr valign="top"><td><code>parameters</code></td> <td> <p>logical; <code>FALSE</code> by default; if <code>TRUE</code> return a list of coordinate reference system parameters, with named elements <code>SemiMajor</code>, <code>InvFlattening</code>, <code>units_gdal</code>, <code>IsVertical</code>, <code>WktPretty</code>, and <code>Wkt</code></p> </td></tr> <tr valign="top"><td><code>value</code></td> <td> <p>one of (i) character: a string accepted by GDAL, (ii) integer, a valid EPSG value (numeric), or (iii) an object of class <code>crs</code>.</p> </td></tr> <tr valign="top"><td><code>name</code></td> <td> <p>element name</p> </td></tr> <tr valign="top"><td><code>authority_compliant</code></td> <td> <p>logical; specify whether axis order should be handled compliant to the authority; if omitted, the current value is printed.</p> </td></tr> </table> <h3>Format</h3> <p>An object of class <code>crs</code> of length 2. </p> <h3>Details</h3> <p>The *crs functions create, get, set or replace the <code>crs</code> attribute of a simple feature geometry list-column. This attribute is of class <code>crs</code>, and is a list consisting of <code>input</code> (user input, e.g. "EPSG:4326" or "WGS84" or a proj4string), and <code>wkt</code>, an automatically generated wkt representation of the crs. </p> <p>Comparison of two objects of class <code>crs</code> uses the GDAL function <code>OGRSpatialReference::IsSame</code>. </p> <p>In case a coordinate reference system is replaced, no transformation takes place and a warning is raised to stress this. </p> <p><code>NA_crs_</code> is the <code>crs</code> object with missing values for <code>input</code> and <code>wkt</code>. </p> <p>the <code>$</code> method for <code>crs</code> objects retrieves named elements using the GDAL interface; named elements include <code>"SemiMajor"</code>, <code>"SemiMinor"</code>, <code>"InvFlattening"</code>, <code>"IsGeographic"</code>, <code>"units_gdal"</code>, <code>"IsVertical"</code>, <code>"WktPretty"</code>, <code>"Wkt"</code>, <code>"Name"</code>, <code>"proj4string"</code>, <code>"epsg"</code>, <code>"yx"</code> and <code>"ud_unit"</code> (this may be subject to changes in future GDAL versions). </p> <p>format.crs returns NA if the crs is missing valued, or else the name of a crs if it is different from "unknown", or else the user input if it was set, or else its "proj4string" representation; </p> <p><code>st_axis_order</code> can be used to get and set the axis order: <code>TRUE</code> indicates axes order according to the authority (e.g. EPSG:4326 defining coordinates to be latitude,longitude pairs), <code>FALSE</code> indicates the usual GIS (display) order (longitude,latitude). This can be useful when data are read, or have to be written, with coordinates in authority compliant order. The return value is the current state of this (<code>FALSE</code>, by default). </p> <h3>Value</h3> <p>If <code>x</code> is numeric, return <code>crs</code> object for EPSG:<code>x</code>; if <code>x</code> is character, return <code>crs</code> object for <code>x</code>; if <code>x</code> is of class <code>sf</code> or <code>sfc</code>, return its <code>crs</code> object. </p> <p>Object of class <code>crs</code>, which is a list with elements <code>input</code> (length-1 character) and <code>wkt</code> (length-1 character). Elements may be <code>NA</code> valued; if all elements are <code>NA</code> the CRS is missing valued, and coordinates are assumed to relate to an arbitrary Cartesian coordinate system. </p> <p><code>st_axis_order</code> returns the (logical) current value if called without argument, or (invisibly) the previous value if it is being set. </p> <h3>Examples</h3> <pre> 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 st_crs("EPSG:3857")$input st_crs(3857)$proj4string st_crs(3857)$b # numeric st_crs(3857)$units # character pt = st_sfc(st_point(c(0, 60)), crs = 4326) # st_axis_order() only has effect in GDAL >= 2.5.0: st_axis_order() # query default: FALSE means interpret pt as (longitude latitude) st_transform(pt, 3857)[[1]] old_value = FALSE if (sf_extSoftVersion()["GDAL"] >= "2.5.0") (old_value = st_axis_order(TRUE)) # now interpret pt as (latitude longitude), as EPSG:4326 prescribes: st_axis_order() # query current value st_transform(pt, 3857)[[1]] st_axis_order(old_value) # set back to old value </pre> <hr /><div style="text-align: center;">[Package <em>sf</em> version 0.9-5 <a href="00Index.html">Index</a>]</div> </body></html>