EVOLUTION-MANAGER
Edit File: as.SpatialPolygons.GridTopology.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: Make SpatialPolygons object from GridTopology object</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 as.SpatialPolygons.GridTopology {sp}"><tr><td>as.SpatialPolygons.GridTopology {sp}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Make SpatialPolygons object from GridTopology object</h2> <h3>Description</h3> <p>Converts grids of regular rectangles into a <code>SpatialPolygons</code> object, which can be transformed to a different projection or datum with <code>spTransform</code> in package <code>rgdal</code>. The function is not suitable for high-resolution grids. The ordering of the grid cells is as in <code>coordinates()</code> of the same object, and is reported by <code>IDvaluesGridTopology</code>. </p> <h3>Usage</h3> <pre> as.SpatialPolygons.GridTopology(grd, proj4string = CRS(as.character(NA))) IDvaluesGridTopology(obj) as.SpatialPolygons.SpatialPixels(obj) IDvaluesSpatialPixels(obj) HexPoints2SpatialPolygons(hex, dx) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>grd</code></td> <td> <p><code>GridTopology</code> object</p> </td></tr> <tr valign="top"><td><code>proj4string</code></td> <td> <p>object of class <a href="CRS-class.html">CRS-class</a></p> </td></tr> <tr valign="top"><td><code>obj</code></td> <td> <p><code>SpatialPixels</code> object </p> </td></tr> <tr valign="top"><td><code>hex</code></td> <td> <p><code>SpatialPoints</code> object with points that are generated by hexagonal sampling; see <a href="spsample.html">spsample</a></p> </td></tr> <tr valign="top"><td><code>dx</code></td> <td> <p> spacing of two horizontally adjacent points; if missing, this will be computed from the points </p> </td></tr> </table> <h3>Value</h3> <p><code>as.SpatialPolygons.GridTopology</code> and <code>as.SpatialPolygons.SpatialPixels</code> return a <code>SpatialPolygons</code> object; <code>IDvaluesGridTopology</code> and <code>IDvaluesSpatialPixels</code> return a character vector with the object grid indices. </p> <h3>See Also</h3> <p><code><a href="SpatialGrid.html">GridTopology</a></code>, <code><a href="SpatialGrid.html">SpatialPixels</a></code>, <code><a href="SpatialPolygons.html">SpatialPolygons</a></code> <code>spTransform</code> in package <code>rgdal</code> </p> <h3>Examples</h3> <pre> library(lattice) grd <- GridTopology(cellcentre.offset=c(-175,55), cellsize=c(10,10), cells.dim=c(4,4)) SpP_grd <- as.SpatialPolygons.GridTopology(grd) plot(SpP_grd) text(coordinates(SpP_grd), sapply(slot(SpP_grd, "polygons"), function(i) slot(i, "ID")), cex=0.5) trdata <- data.frame(A=rep(c(1,2,3,4), 4), B=rep(c(1,2,3,4), each=4), row.names=sapply(slot(SpP_grd, "polygons"), function(i) slot(i, "ID"))) SpPDF <- SpatialPolygonsDataFrame(SpP_grd, trdata) spplot(SpPDF) data(meuse.grid) gridded(meuse.grid)=~x+y xx = spsample(meuse.grid, type="hexagonal", cellsize=200) xxpl = HexPoints2SpatialPolygons(xx) image(meuse.grid["dist"]) plot(xxpl, add = TRUE) points(xx, cex = .5) ## Not run: spplot(aggregate(as(meuse.grid[,1:3], "SpatialPolygonsDataFrame"), xxpl, areaWeighted=TRUE), main = "aggregated meuse.grid") ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>sp</em> version 1.4-2 <a href="00Index.html">Index</a>]</div> </body></html>