EVOLUTION-MANAGER
Edit File: CRS-class.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: Class "CRS" of coordinate reference system arguments</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 CRS-class {sp}"><tr><td>CRS-class {sp}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Class "CRS" of coordinate reference system arguments</h2> <h3>Description</h3> <p>Interface class to the PROJ projection and transformation system. The class is defined as an empty stub accepting value NA in the sp package. The initiation function may call the PROJ library through <span class="pkg">rgdal</span> to verify the argument set against those known in the library, returning error messages where necessary. If the <code>"CRS"</code> object is instantiated using <code>CRS()</code> with <span class="pkg">rgdal</span> using PROJ >= 6 and GDAL >= 3, the object may also have a WKT2 (2019) string carried as a <code>comment</code>. The arguments for a Proj.4 string must be entered exactly as in the Proj.4 documentation, in particular there cannot be any white space in <code>+<key>=<value></code> strings, and successive such strings can only be separated by blanks. Note that only “+proj=longlat +ellps=WGS84” is accepted for geographical coordinates, which must be ordered (eastings, northings); the “+ellps=” definition must be given (or expanded internally from a given “+datum=” value) for recent versions of the Proj.4 library, and should be set to an appropriate value.</p> <h3>Usage</h3> <pre> CRS(projargs, doCheckCRSArgs=TRUE, SRS_string=NULL) identicalCRS(x,y) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>projargs</code></td> <td> <p>A character string of projection arguments; the arguments must be entered exactly as in the PROJ.4 documentation; if the projection is unknown, use <code>as.character(NA)</code>, it may be missing or an empty string of zero length and will then set to the missing value.</p> </td></tr> <tr valign="top"><td><code>doCheckCRSArgs</code></td> <td> <p>default TRUE, must be set to FALSE by package developers including <code>CRS</code> in an S4 class definition to avoid uncontrollable loading of the <span class="pkg">rgdal</span> namespace</p> </td></tr> <tr valign="top"><td><code>SRS_string</code></td> <td> <p>default NULL, only used when <span class="pkg">rgdal</span> is built with PROJ >= 6 and GDAL >= 3; a valid WKT string or SRS definition such as <code>"EPSG:4326"</code></p> </td></tr> <tr valign="top"><td><code>x</code></td> <td> <p>object having a <a href="is.projected.html">proj4string</a> method, or if <code>y</code> is missing, list with objects that have a <code>proj4string</code> method</p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>object of class <a href="Spatial-class.html">Spatial</a>, or having a <a href="is.projected.html">proj4string</a> method</p> </td></tr> </table> <h3>Value</h3> <p><code>CRS</code> returns on success an object of class <a href="CRS-class.html">CRS</a>. <code>identicalCRS</code> returns a logical, indicating whether <code>x</code> and <code>y</code> have identical CRS, or if <code>y</code> is missing whether all objects in list <code>x</code> have identical CRS. </p> <h3>Objects from the Class</h3> <p>Objects can be created by calls of the form <code>CRS("projargs")</code>, where "projargs" is a valid string of PROJ.4 arguments. If the argument is a zero-length string or a character <code>NA</code>, the object records <code>NA</code>. If the <code>"CRS"</code> object is instantiated using <code>CRS()</code> with <span class="pkg">rgdal</span> using PROJ >= 6 and GDAL >= 3, the object may also have a WKT2 (2019) string carried as a <code>comment</code>. The initiation function may call the PROJ library through <span class="pkg">rgdal</span> to verify the argument set against those known in the library, returning error messages where necessary. The function <code>CRSargs()</code> can be used to show the expanded Proj.4 string used by the PROJ library. </p> <h3>Slots</h3> <dl> <dt><code>projargs</code>:</dt><dd><p>Object of class <code>"character"</code>: projection arguments; the arguments must be entered exactly as in the PROJ.4 documentation, in particular there cannot be any white space in +<arg>=<value> strings, and successive such strings can only be separated by blanks. </p> </dd> </dl> <h3>Methods</h3> <dl> <dt>show</dt><dd><p><code>signature(object = "CRS")</code>: print projection arguments in object </p> </dd> <dt>wkt</dt><dd><p><code>signature(object = "CRS")</code>: return WKT comment on object</p> </dd> <dt>rebuild_CRS</dt><dd><p>rebuild a CRS object, usually used to add a WKT comment with PROJ >= 6 and GDAL >= 3</p> </dd> </dl> <h3>Note</h3> <p>Lists of projections may be seen by using the programs installed with the PROJ.4 library, in particular proj and cs2cs; with the latter, -lp lists projections, -le ellipsoids, -lu units, and -ld datum(s) known to the installed software (available in <span class="pkg">rgdal</span> using <code>projInfo</code>). These are added to in successive releases, so tracking the website or compiling and installing the most recent revisions will give the greatest choice. Finding the very important datum transformation parameters to be given with the +towgs84 tag is a further challenge, and is essential when the datums used in data to be used together differ. Tracing projection arguments is easier now than before the mass ownership of GPS receivers raised the issue of matching coordinates from different argument sets (GPS output and paper map, for example). See <code><a href="../../rgdal/html/GridsDatums.html">GridsDatums</a></code>, <code><a href="../../rgdal/html/make_EPSG.html">make_EPSG</a></code> and <code><a href="../../rgdal/html/showEPSG.html">showEPSG</a></code> for help in finding CRS definitions. </p> <p>The 4.9.1 release of the PROJ library omitted a small file of defaults, leading to reports of “major axis or radius = 0 or not given” errors. From 0.9-3, rgdal checks for the presence of this file (proj_def.dat), and if not found, and under similar conditions to those used by PROJ.4, adds “+ellps=WGS84” to the input string being checked by <code>checkCRSArgs</code> The “+no_defs” tag ignores the file of defaults, and the default work-around implemented to get around this problem; strings including “init” and “datum” tags also trigger the avoidance of the work-around. Now messages are issued when a candidate CRS is checked; they may be suppressed using <code>suppressMessages</code>. </p> <p>From release 6 of the PROJ library, when used in building <span class="pkg">rgdal</span> with GDAL >= 3, the <code>+datum=</code> key in the Proj.4 string CRS representation is deprecated, and the <code>+towgs84=</code> and <code>+nadgrids=</code> keys may be deprecated soon. For this reason, <span class="pkg">sp</span>, <span class="pkg">rgdal</span> and <span class="pkg">sf</span> are starting to use WKT2 (2019) string representations. In <span class="pkg">sp</span>, the <code>"CRS"</code> object in itself remains unchanged, but the content of its <code>"projargs"</code> slot may be degraded. To work around the degradation, a <code>comment</code> is added around the <code>"CRS"</code> object containing a WKT2 (2019) string when <span class="pkg">rgdal</span> is available and built with PROJ >= 6 and GDAL >=3. </p> <h3>Author(s)</h3> <p>Roger Bivand <a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a></p> <h3>References</h3> <p><a href="https://github.com/OSGeo/proj.4">https://github.com/OSGeo/proj.4</a></p> <h3>Examples</h3> <pre> CRS() CRS("") CRS(as.character(NA)) CRS("+proj=longlat +datum=WGS84") if (require(rgdal)) { print(CRSargs(CRS("+proj=longlat +datum=NAD27"))) print(CRSargs(CRS("+init=epsg:4267"))) print(CRSargs(CRS("+init=epsg:26978"))) print(CRSargs(CRS(paste("+proj=sterea +lat_0=52.15616055555555", "+lon_0=5.38763888888889 +k=0.999908 +x_0=155000 +y_0=463000 +ellps=bessel", " +towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812 +units=m")))) print(CRSargs(CRS("+init=epsg:28992"))) } # see http://trac.osgeo.org/gdal/ticket/1987 o <- new("Spatial") proj4string(o) <- CRS("+init=epsg:27700") if (!is.null(comment(slot(o, "proj4string")))) { cat(strsplit(wkt(o), "\n")[[1]], sep="\n") cat(strsplit(wkt(slot(o, "proj4string")), "\n")[[1]], sep="\n") } </pre> <hr /><div style="text-align: center;">[Package <em>sp</em> version 1.4-2 <a href="00Index.html">Index</a>]</div> </body></html>