EVOLUTION-MANAGER
Edit File: geos_measures.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: Compute geometric measurements</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 geos_measures {sf}"><tr><td>geos_measures {sf}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Compute geometric measurements</h2> <h3>Description</h3> <p>Compute Euclidian or great circle distance between pairs of geometries; compute, the area or the length of a set of geometries. </p> <h3>Usage</h3> <pre> st_area(x, ...) ## S3 method for class 'sfc' st_area(x, ...) st_length(x, ...) st_distance( x, y, ..., dist_fun, by_element = FALSE, which = ifelse(isTRUE(st_is_longlat(x)), "Great Circle", "Euclidean"), par = 0, tolerance = 0 ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>object of class <code>sf</code>, <code>sfc</code> or <code>sfg</code></p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>ignored</p> </td></tr> <tr valign="top"><td><code>y</code></td> <td> <p>object of class <code>sf</code>, <code>sfc</code> or <code>sfg</code>, defaults to <code>x</code></p> </td></tr> <tr valign="top"><td><code>dist_fun</code></td> <td> <p>deprecated</p> </td></tr> <tr valign="top"><td><code>by_element</code></td> <td> <p>logical; if <code>TRUE</code>, return a vector with distance between the first elements of <code>x</code> and <code>y</code>, the second, etc. if <code>FALSE</code>, return the dense matrix with all pairwise distances.</p> </td></tr> <tr valign="top"><td><code>which</code></td> <td> <p>character; for Cartesian coordinates only: one of <code>Euclidean</code>, <code>Hausdorff</code> or <code>Frechet</code>; for geodetic coordinates, great circle distances are computed; see details</p> </td></tr> <tr valign="top"><td><code>par</code></td> <td> <p>for <code>which</code> equal to <code>Hausdorff</code> or <code>Frechet</code>, optionally use a value between 0 and 1 to densify the geometry</p> </td></tr> <tr valign="top"><td><code>tolerance</code></td> <td> <p>ignored if <code>st_is_longlat(x)</code> is <code>FALSE</code>; otherwise, if set to a positive value, the first distance smaller than <code>tolerance</code> will be returned, and true distance may be smaller; this may speed up computation. In meters, or a <code>units</code> object convertible to meters.</p> </td></tr> </table> <h3>Details</h3> <p>great circle distance calculations use function <code>geod_inverse</code> from PROJ; see Karney, Charles FF, 2013, Algorithms for geodesics, Journal of Geodesy 87(1), 43–55 </p> <h3>Value</h3> <p>If the coordinate reference system of <code>x</code> was set, these functions return values with unit of measurement; see <a href="../../units/html/set_units.html">set_units</a>. </p> <p>st_area returns the area of a geometry, in the coordinate reference system used; in case <code>x</code> is in degrees longitude/latitude, <a href="../../lwgeom/html/geod.html">st_geod_area</a> is used for area calculation. </p> <p>st_length returns the length of a <code>LINESTRING</code> or <code>MULTILINESTRING</code> geometry, using the coordinate reference system. <code>POINT</code>, <code>MULTIPOINT</code>, <code>POLYGON</code> or <code>MULTIPOLYGON</code> geometries return zero. </p> <p>If <code>by_element</code> is <code>FALSE</code> <code>st_distance</code> returns a dense numeric matrix of dimension length(x) by length(y); otherwise it returns a numeric vector of length <code>x</code> or <code>y</code>, the shorter one being recycled. Distances involving empty geometries are <code>NA</code>. </p> <h3>See Also</h3> <p><a href="geos_query.html">st_dimension</a>, <a href="st_cast.html">st_cast</a> to convert geometry types </p> <h3>Examples</h3> <pre> b0 = st_polygon(list(rbind(c(-1,-1), c(1,-1), c(1,1), c(-1,1), c(-1,-1)))) b1 = b0 + 2 b2 = b0 + c(-0.2, 2) x = st_sfc(b0, b1, b2) st_area(x) line = st_sfc(st_linestring(rbind(c(30,30), c(40,40))), crs = 4326) st_length(line) outer = matrix(c(0,0,10,0,10,10,0,10,0,0),ncol=2, byrow=TRUE) hole1 = matrix(c(1,1,1,2,2,2,2,1,1,1),ncol=2, byrow=TRUE) hole2 = matrix(c(5,5,5,6,6,6,6,5,5,5),ncol=2, byrow=TRUE) poly = st_polygon(list(outer, hole1, hole2)) mpoly = st_multipolygon(list( list(outer, hole1, hole2), list(outer + 12, hole1 + 12) )) st_length(st_sfc(poly, mpoly)) p = st_sfc(st_point(c(0,0)), st_point(c(0,1)), st_point(c(0,2))) st_distance(p, p) st_distance(p, p, by_element = TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>sf</em> version 0.9-5 <a href="00Index.html">Index</a>]</div> </body></html>