EVOLUTION-MANAGER
Edit File: st_transform.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: Transform or convert coordinates of simple feature</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_transform {sf}"><tr><td>st_transform {sf}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Transform or convert coordinates of simple feature</h2> <h3>Description</h3> <p>Transform or convert coordinates of simple feature </p> <h3>Usage</h3> <pre> st_transform(x, crs, ...) ## S3 method for class 'sfc' st_transform( x, crs = st_crs(x), ..., aoi = numeric(0), pipeline = character(0), reverse = FALSE, partial = TRUE, check = FALSE ) ## S3 method for class 'sf' st_transform(x, crs = st_crs(x), ...) ## S3 method for class 'sfg' st_transform(x, crs = st_crs(x), ...) sf_proj_info(type = "proj", path) st_wrap_dateline(x, options, quiet) ## S3 method for class 'sfc' st_wrap_dateline(x, options = "WRAPDATELINE=YES", quiet = TRUE) ## S3 method for class 'sf' st_wrap_dateline(x, options = "WRAPDATELINE=YES", quiet = TRUE) ## S3 method for class 'sfg' st_wrap_dateline(x, options = "WRAPDATELINE=YES", quiet = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>object of class sf, sfc or sfg</p> </td></tr> <tr valign="top"><td><code>crs</code></td> <td> <p>coordinate reference system: integer with the EPSG code, or character with proj4string</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>ignored</p> </td></tr> <tr valign="top"><td><code>aoi</code></td> <td> <p>area of interest, in degrees: WestLongitude, SouthLatitude, EastLongitude, NorthLatitude</p> </td></tr> <tr valign="top"><td><code>pipeline</code></td> <td> <p>character; proj4 or WKT coordinate operation, to override the default operation</p> </td></tr> <tr valign="top"><td><code>reverse</code></td> <td> <p>boolean; if <code>TRUE</code>, the inverse operation of the pipeline is applied</p> </td></tr> <tr valign="top"><td><code>partial</code></td> <td> <p>logical; allow for partial projection, if not all points of a geometry can be projected (corresponds to setting environment variable <code>OGR_ENABLE_PARTIAL_REPROJECTION</code> to <code>TRUE</code>)</p> </td></tr> <tr valign="top"><td><code>check</code></td> <td> <p>logical; perform a sanity check on resulting polygons?</p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p>character; one of <code>have_datum_files</code>, <code>proj</code>, <code>ellps</code>, <code>datum</code>, <code>units</code> or <code>prime_meridians</code>; see Details.</p> </td></tr> <tr valign="top"><td><code>path</code></td> <td> <p>character; PROJ search path to be set</p> </td></tr> <tr valign="top"><td><code>options</code></td> <td> <p>character; should have "WRAPDATELINE=YES" to function; another parameter that is used is "DATELINEOFFSET=10" (where 10 is the default value)</p> </td></tr> <tr valign="top"><td><code>quiet</code></td> <td> <p>logical; print options after they have been parsed?</p> </td></tr> </table> <h3>Details</h3> <p>Transforms coordinates of object to new projection. Features that cannot be transformed are returned as empty geometries. </p> <p>Projecting to projections not supported by GDAL may be done by <a href="../../lwgeom/html/st_transform_proj.html">st_transform_proj</a>, part of package lwgeom. </p> <p>The <code>st_transform</code> method for <code>sfg</code> objects assumes that the CRS of the object is available as an attribute of that name. </p> <p><code>sf_proj_info</code> lists the available projections, ellipses, datums, units, or data search path of the PROJ library when <code>type</code> is equal to proj, ellps, datum, units or path; when <code>type</code> equals <code>have_datum_files</code> a boolean is returned indicating whether datum files are installed and accessible (checking for <code>conus</code>). </p> <p>for PROJ >= 6, <code>sf_proj_info</code> does not provide option <code>type = "datums"</code>. PROJ < 6 does not provide the option <code>type = "prime_meridians"</code>. </p> <p>for PROJ >= 7.1.0, the "units" query of <code>sf_proj_info</code> returns the <code>to_meter</code> variable as numeric, previous versions return a character vector containing a numeric expression. </p> <p>For a discussion of using <code>options</code>, see <a href="https://github.com/r-spatial/sf/issues/280">https://github.com/r-spatial/sf/issues/280</a> and <a href="https://github.com/r-spatial/sf/issues/541">https://github.com/r-spatial/sf/issues/541</a> </p> <h3>Examples</h3> <pre> p1 = st_point(c(7,52)) p2 = st_point(c(-30,20)) sfc = st_sfc(p1, p2, crs = 4326) sfc st_transform(sfc, 3857) st_transform(st_sf(a=2:1, geom=sfc), "+init=epsg:3857") try(st_transform(sfc, 3857, aoi = c(-280,-90,180,90))) if (sf_extSoftVersion()["GDAL"] >= "3.0.0") { st_transform(sfc, pipeline = "+proj=pipeline +step +proj=axisswap +order=2,1") # reverse axes st_transform(sfc, pipeline = "+proj=pipeline +step +proj=axisswap +order=2,1", reverse = TRUE) # also reverse axes } nc = st_read(system.file("shape/nc.shp", package="sf")) st_area(nc[1,]) # area from long/lat st_area(st_transform(nc[1,], 32119)) # NC state plane, m st_area(st_transform(nc[1,], 2264)) # NC state plane, US foot library(units) set_units(st_area(st_transform(nc[1,], 2264)), m^2) st_transform(structure(p1, proj4string = "+init=epsg:4326"), "+init=epsg:3857") sf_proj_info("datum") st_wrap_dateline(st_sfc(st_linestring(rbind(c(-179,0),c(179,0))), crs = 4326)) library(maps) wrld <- st_as_sf(maps::map("world", fill = TRUE, plot = FALSE)) wrld_wrap <- st_wrap_dateline(wrld, options = c("WRAPDATELINE=YES", "DATELINEOFFSET=180"), quiet = TRUE) wrld_moll <- st_transform(wrld_wrap, "+proj=moll") plot(st_geometry(wrld_moll), col = "transparent") </pre> <hr /><div style="text-align: center;">[Package <em>sf</em> version 0.9-5 <a href="00Index.html">Index</a>]</div> </body></html>