EVOLUTION-MANAGER
Edit File: st.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: Create simple feature from a numeric vector, matrix or list</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 {sf}"><tr><td>st {sf}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create simple feature from a numeric vector, matrix or list</h2> <h3>Description</h3> <p>Create simple feature from a numeric vector, matrix or list </p> <h3>Usage</h3> <pre> st_point(x = c(NA_real_, NA_real_), dim = "XYZ") st_multipoint(x = matrix(numeric(0), 0, 2), dim = "XYZ") st_linestring(x = matrix(numeric(0), 0, 2), dim = "XYZ") st_polygon(x = list(), dim = if (length(x)) "XYZ" else "XY") st_multilinestring(x = list(), dim = if (length(x)) "XYZ" else "XY") st_multipolygon(x = list(), dim = if (length(x)) "XYZ" else "XY") st_geometrycollection(x = list(), dims = "XY") ## S3 method for class 'sfg' print(x, ..., width = 0) ## S3 method for class 'sfg' head(x, n = 10L, ...) ## S3 method for class 'sfg' format(x, ..., width = 30) ## S3 method for class 'sfg' c(..., recursive = FALSE, flatten = TRUE) ## S3 method for class 'sfg' as.matrix(x, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>for <code>st_point</code>, numeric vector (or one-row-matrix) of length 2, 3 or 4; for <code>st_linestring</code> and <code>st_multipoint</code>, numeric matrix with points in rows; for <code>st_polygon</code> and <code>st_multilinestring</code>, list with numeric matrices with points in rows; for <code>st_multipolygon</code>, list of lists with numeric matrices; for <code>st_geometrycollection</code> list with (non-geometrycollection) simple feature objects</p> </td></tr> <tr valign="top"><td><code>dim</code></td> <td> <p>character, indicating dimensions: "XY", "XYZ", "XYM", or "XYZM"; only really needed for three-dimensional points (which can be either XYZ or XYM) or empty geometries; see details</p> </td></tr> <tr valign="top"><td><code>dims</code></td> <td> <p>character; specify dimensionality in case of an empty (NULL) geometrycollection, in which case <code>x</code> is the empty <code>list()</code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>objects to be pasted together into a single simple feature</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>integer; number of characters to be printed (max 30; 0 means print everything)</p> </td></tr> <tr valign="top"><td><code>n</code></td> <td> <p>integer; number of elements to be selected</p> </td></tr> <tr valign="top"><td><code>recursive</code></td> <td> <p>logical; ignored</p> </td></tr> <tr valign="top"><td><code>flatten</code></td> <td> <p>logical; if TRUE, try to simplify results; if FALSE, return geometrycollection containing all objects</p> </td></tr> </table> <h3>Details</h3> <p>"XYZ" refers to coordinates where the third dimension represents altitude, "XYM" refers to three-dimensional coordinates where the third dimension refers to something else ("M" for measure); checking of the sanity of <code>x</code> may be only partial. </p> <p>When <code>flatten=TRUE</code>, this method may merge points into a multipoint structure, and may not preserve order, and hence cannot be reverted. When given fish, it returns fish soup. </p> <h3>Value</h3> <p>object of the same nature as <code>x</code>, but with appropriate class attribute set </p> <p>as.matrix returns the set of points that form a geometry as a single matrix, where each point is a row; use <code>unlist(x, recursive = FALSE)</code> to get sets of matrices. </p> <h3>Examples</h3> <pre> (p1 = st_point(c(1,2))) class(p1) st_bbox(p1) (p2 = st_point(c(1,2,3))) class(p2) (p3 = st_point(c(1,2,3), "XYM")) pts = matrix(1:10, , 2) (mp1 = st_multipoint(pts)) pts = matrix(1:15, , 3) (mp2 = st_multipoint(pts)) (mp3 = st_multipoint(pts, "XYM")) pts = matrix(1:20, , 4) (mp4 = st_multipoint(pts)) pts = matrix(1:10, , 2) (ls1 = st_linestring(pts)) pts = matrix(1:15, , 3) (ls2 = st_linestring(pts)) (ls3 = st_linestring(pts, "XYM")) pts = matrix(1:20, , 4) (ls4 = st_linestring(pts)) 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) pts = list(outer, hole1, hole2) (ml1 = st_multilinestring(pts)) pts3 = lapply(pts, function(x) cbind(x, 0)) (ml2 = st_multilinestring(pts3)) (ml3 = st_multilinestring(pts3, "XYM")) pts4 = lapply(pts3, function(x) cbind(x, 0)) (ml4 = st_multilinestring(pts4)) 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) pts = list(outer, hole1, hole2) (pl1 = st_polygon(pts)) pts3 = lapply(pts, function(x) cbind(x, 0)) (pl2 = st_polygon(pts3)) (pl3 = st_polygon(pts3, "XYM")) pts4 = lapply(pts3, function(x) cbind(x, 0)) (pl4 = st_polygon(pts4)) pol1 = list(outer, hole1, hole2) pol2 = list(outer + 12, hole1 + 12) pol3 = list(outer + 24) mp = list(pol1,pol2,pol3) (mp1 = st_multipolygon(mp)) pts3 = lapply(mp, function(x) lapply(x, function(y) cbind(y, 0))) (mp2 = st_multipolygon(pts3)) (mp3 = st_multipolygon(pts3, "XYM")) pts4 = lapply(mp2, function(x) lapply(x, function(y) cbind(y, 0))) (mp4 = st_multipolygon(pts4)) (gc = st_geometrycollection(list(p1, ls1, pl1, mp1))) st_geometrycollection() # empty geometry c(st_point(1:2), st_point(5:6)) c(st_point(1:2), st_multipoint(matrix(5:8,2))) c(st_multipoint(matrix(1:4,2)), st_multipoint(matrix(5:8,2))) c(st_linestring(matrix(1:6,3)), st_linestring(matrix(11:16,3))) c(st_multilinestring(list(matrix(1:6,3))), st_multilinestring(list(matrix(11:16,3)))) pl = list(rbind(c(0,0), c(1,0), c(1,1), c(0,1), c(0,0))) c(st_polygon(pl), st_polygon(pl)) c(st_polygon(pl), st_multipolygon(list(pl))) c(st_linestring(matrix(1:6,3)), st_point(1:2)) c(st_geometrycollection(list(st_point(1:2), st_linestring(matrix(1:6,3)))), st_geometrycollection(list(st_multilinestring(list(matrix(11:16,3)))))) c(st_geometrycollection(list(st_point(1:2), st_linestring(matrix(1:6,3)))), st_multilinestring(list(matrix(11:16,3))), st_point(5:6), st_geometrycollection(list(st_point(10:11)))) </pre> <hr /><div style="text-align: center;">[Package <em>sf</em> version 0.9-5 <a href="00Index.html">Index</a>]</div> </body></html>