EVOLUTION-MANAGER
Edit File: SpatialPoints.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 objects of class SpatialPoints or...</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 SpatialPoints {sp}"><tr><td>SpatialPoints {sp}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> create objects of class SpatialPoints or SpatialPointsDataFrame</h2> <h3>Description</h3> <p> create objects of class <a href="SpatialPoints-class.html">SpatialPoints-class</a> or <a href="SpatialPointsDataFrame-class.html">SpatialPointsDataFrame-class</a> from coordinates, and from coordinates and <code>data.frame</code>s</p> <h3>Usage</h3> <pre> SpatialPoints(coords, proj4string=CRS(as.character(NA)), bbox = NULL) SpatialPointsDataFrame(coords, data, coords.nrs = numeric(0), proj4string = CRS(as.character(NA)), match.ID, bbox = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>coords</code></td> <td> <p>numeric matrix or data.frame with coordinates (each row is a point); in case of SpatialPointsDataFrame an object of class <a href="SpatialPoints-class.html">SpatialPoints-class</a> is also allowed</p> </td></tr> <tr valign="top"><td><code>proj4string</code></td> <td> <p> projection string of class <a href="CRS-class.html">CRS-class</a></p> </td></tr> <tr valign="top"><td><code>bbox</code></td> <td> <p>bounding box matrix, usually NULL and constructed from the data, but may be passed through for coercion purposes if clearly needed</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p> object of class <code>data.frame</code>; the number of rows in <code>data</code> should equal the number of points in the <code>coords</code> object</p> </td></tr> <tr valign="top"><td><code>coords.nrs</code></td> <td> <p>numeric; if present, records the column positions where in <code>data</code> the coordinates were taken from (used by <a href="coordinates.html">coordinates<-</a>)</p> </td></tr> <tr valign="top"><td><code>match.ID</code></td> <td> <p> logical or character; if missing, and <code>coords</code> and <code>data</code> both have row names, and their order does not correspond, matching is done by these row names and a warning is issued; this warning can be suppressed by setting <code>match.ID</code> to TRUE. If TRUE AND coords has non-automatic rownames (i.e., coerced to a matrix by <code>as.matrix</code>, <code>dimnames(coords)[[1]]</code> is not <code>NULL</code>), AND <code>data</code> has row.names (i.e. is a data.frame), then the <code>SpatialPointsDataFrame</code> object is formed by matching the row names of both components, leaving the order of the coordinates in tact. Checks are done to see whether both row names are sufficiently unique, and all data are matched. If FALSE, coordinates and data are simply "glued" together, ignoring row names. If character: indicates the column in <code>data</code> with coordinates IDs to use for matching records. See examples below. </p> </td></tr> </table> <h3>Value</h3> <p><code>SpatialPoints</code> returns an object of class <code>SpatialPoints</code>; <code>SpatialPointsDataFrame</code> returns an object of class <code>SpatialPointsDataFrame</code>; </p> <h3>See Also</h3> <p><a href="coordinates.html">coordinates</a>, <a href="SpatialPoints-class.html">SpatialPoints-class</a>, <a href="SpatialPointsDataFrame-class.html">SpatialPointsDataFrame-class</a> </p> <h3>Examples</h3> <pre> set.seed(1331) pts = cbind(1:5, 1:5) dimnames(pts)[[1]] = letters[1:5] df = data.frame(a = 1:5) row.names(df) = letters[5:1] library(sp) options(warn=1) # show warnings where they occur SpatialPointsDataFrame(pts, df) # warn SpatialPointsDataFrame(pts, df, match.ID = TRUE) # don't warn SpatialPointsDataFrame(pts, df, match.ID = FALSE) # don't warn df$m = letters[5:1] SpatialPointsDataFrame(pts, df, match.ID = "m") # don't warn dimnames(pts)[[1]] = letters[5:1] SpatialPointsDataFrame(pts, df) # don't warn: ID matching doesn't reorder </pre> <hr /><div style="text-align: center;">[Package <em>sp</em> version 1.4-2 <a href="00Index.html">Index</a>]</div> </body></html>