EVOLUTION-MANAGER
Edit File: image.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: Image or contour method for gridded spatial data; convert to...</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 image.SpatialGridDataFrame {sp}"><tr><td>image.SpatialGridDataFrame {sp}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Image or contour method for gridded spatial data; convert to and from image data structure </h2> <h3>Description</h3> <p> Create image for gridded data in SpatialGridDataFrame or SpatialPixelsDataFrame objects. </p> <h3>Usage</h3> <pre> ## S3 method for class 'SpatialGridDataFrame' image(x, attr = 1, xcol = 1, ycol = 2, col = heat.colors(12), red=NULL, green=NULL, blue=NULL, axes = FALSE, xlim = NULL, ylim = NULL, add = FALSE, ..., asp = NA, setParUsrBB=FALSE, interpolate = FALSE, angle = 0, useRasterImage = !(.Platform$GUI[1] == "Rgui" && getIdentification() == "R Console") && missing(breaks), breaks, zlim = range(as.numeric(x[[attr]])[is.finite(x[[attr]])])) ## S3 method for class 'SpatialPixelsDataFrame' image(x, ...) ## S3 method for class 'SpatialPixels' image(x, ...) ## S3 method for class 'SpatialGridDataFrame' contour(x, attr = 1, xcol = 1, ycol = 2, col = 1, add = FALSE, xlim = NULL, ylim = NULL, axes = FALSE, ..., setParUsrBB = FALSE) ## S3 method for class 'SpatialPixelsDataFrame' contour(x, ...) as.image.SpatialGridDataFrame(x, xcol = 1, ycol = 2, attr = 1) image2Grid(im, p4 = as.character(NA), digits=10) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> object of class <a href="SpatialGridDataFrame.html">SpatialGridDataFrame</a> </p> </td></tr> <tr valign="top"><td><code>attr</code></td> <td> <p> column of attribute variable; this may be the column name in the data.frame of <code>data</code> (as.data.frame(data)), or a column number </p> </td></tr> <tr valign="top"><td><code>xcol</code></td> <td> <p> column number of x-coordinate, in the coordinate matrix </p> </td></tr> <tr valign="top"><td><code>ycol</code></td> <td> <p> column number of y-coordinate, in the coordinate matrix </p> </td></tr> <tr valign="top"><td><code>col</code></td> <td> <p>a vector of colors </p> </td></tr> <tr valign="top"><td><code>red,green,blue</code></td> <td> <p>columns names or numbers given instead of the <code>attr</code> argument when the data represent an image encoded in three colour bands on the 0-255 integer scale; all three columns must be given in this case, and the attribute values will be constructed using function <code>rgb</code> </p> </td></tr> </table> <table summary="R argblock"> <tr valign="top"><td><code>axes</code></td> <td> <p> logical; should coordinate axes be drawn? </p> </td></tr> <tr valign="top"><td><code>xlim</code></td> <td> <p> x-axis limits </p> </td></tr> <tr valign="top"><td><code>ylim</code></td> <td> <p> y-axis limits </p> </td></tr> <tr valign="top"><td><code>zlim</code></td> <td> <p> data limits for plotting the (raster, attribute) values </p> </td></tr> <tr valign="top"><td><code>add</code></td> <td> <p> logical; if FALSE, the image is added to the plot layout setup by <code>plot(as(x, "Spatial"),axes=axes,xlim=xlim,ylim=ylim,asp=asp)</code> which sets up axes and plotting region; if TRUE, the image is added to the existing plot. </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> arguments passed to <a href="../../graphics/html/image.html">image</a>, see examples </p> </td></tr> <tr valign="top"><td><code>asp</code></td> <td> <p> aspect ratio to be used for plot </p> </td></tr> <tr valign="top"><td><code>setParUsrBB</code></td> <td> <p>default FALSE, see <code><a href="Spatial-class.html">Spatial-class</a></code> for further details</p> </td></tr> <tr valign="top"><td><code>useRasterImage</code></td> <td> <p>if TRUE, use <code><a href="../../graphics/html/rasterImage.html">rasterImage</a></code> to render the image if available; for legacy rendering set FALSE; should be FALSE on Windows SDI installations</p> </td></tr> <tr valign="top"><td><code>breaks</code></td> <td> <p>class breaks for coloured values</p> </td></tr> <tr valign="top"><td><code>interpolate</code></td> <td> <p>default FALSE, a logical vector (or scalar) indicating whether to apply linear interpolation to the image when drawing, see <code><a href="../../graphics/html/rasterImage.html">rasterImage</a></code></p> </td></tr> <tr valign="top"><td><code>angle</code></td> <td> <p>default 0, angle of rotation (in degrees, anti-clockwise from positive x-axis, about the bottom-left corner), see <code><a href="../../graphics/html/rasterImage.html">rasterImage</a></code></p> </td></tr> <tr valign="top"><td><code>im</code></td> <td> <p>list with components named x, y, and z, as used for <code>image</code></p> </td></tr> <tr valign="top"><td><code>p4</code></td> <td> <p>CRS object, proj4 string</p> </td></tr> <tr valign="top"><td><code>digits</code></td> <td> <p>default 10, number of significant digits to use for checking equal row/column spacing</p> </td></tr> </table> <h3>Value</h3> <p><code>as.image.SpatialGridDataFrame</code> returns the list with elements <code>x</code> and <code>y</code>, containing the coordinates of the cell centres of a matrix <code>z</code>, containing the attribute values in matrix form as needed by <a href="../../graphics/html/image.html">image</a>. </p> <h3>Note</h3> <p> Providing <code>xcol</code> and <code>ycol</code> attributes seems obsolete, and it is for 2D data, but it may provide opportunities for plotting certain slices in 3D data. I haven't given this much thought yet. </p> <p><a href="../../graphics/html/filled.contour.html">filled.contour</a> seems to misinterpret the coordinate values, if we take the image.default manual page as the reference. </p> <h3>Author(s)</h3> <p> Edzer Pebesma </p> <h3>See Also</h3> <p><a href="../../graphics/html/image.html">image.default</a>, <a href="SpatialGridDataFrame-class.html">SpatialGridDataFrame-class</a>, <a href="../../lattice/html/levelplot.html">levelplot</a> in package <code>lattice</code>. Function <code>image.plot</code> in package <code>fields</code> can be used to make a legend for an image, see an example in <a href="https://stat.ethz.ch/pipermail/r-sig-geo/2007-June/002143.html">https://stat.ethz.ch/pipermail/r-sig-geo/2007-June/002143.html</a> </p> <h3>Examples</h3> <pre> data(meuse.grid) coordinates(meuse.grid) = c("x", "y") # promote to SpatialPointsDataFrame gridded(meuse.grid) = TRUE # promote to SpatialGridDataFrame data(meuse) coordinates(meuse) = c("x", "y") image(meuse.grid["dist"], main = "Distance to river Meuse") points(coordinates(meuse), pch = "+") image(meuse.grid["dist"], main = "Distance to river Meuse", useRasterImage=TRUE) points(coordinates(meuse), pch = "+") # color scale: layout(cbind(1,2), c(4,1),1) image(meuse.grid["dist"]) imageScale(meuse.grid$dist, axis.pos=4, add.axis=FALSE) axis(4,at=c(0,.2,.4,.8), las=2) data(Rlogo) d = dim(Rlogo) cellsize = abs(c(gt[2],gt[6])) cells.dim = c(d[1], d[2]) # c(d[2],d[1]) cellcentre.offset = c(x = gt[1] + 0.5 * cellsize[1], y = gt[4] - (d[2] - 0.5) * abs(cellsize[2])) grid = GridTopology(cellcentre.offset, cellsize, cells.dim) df = as.vector(Rlogo[,,1]) for (band in 2:d[3]) df = cbind(df, as.vector(Rlogo[,,band])) df = as.data.frame(df) names(df) = paste("band", 1:d[3], sep="") Rlogo <- SpatialGridDataFrame(grid = grid, data = df) summary(Rlogo) image(Rlogo, red="band1", green="band2", blue="band3") image(Rlogo, red="band1", green="band2", blue="band3", useRasterImage=FALSE) is.na(Rlogo$band1) <- Rlogo$band1 == 255 is.na(Rlogo$band2) <- Rlogo$band2 == 255 is.na(Rlogo$band3) <- Rlogo$band3 == 255 Rlogo$i7 <- 7 image(Rlogo, "i7") image(Rlogo, red="band1", green="band2", blue="band3", add=TRUE) </pre> <hr /><div style="text-align: center;">[Package <em>sp</em> version 1.4-2 <a href="00Index.html">Index</a>]</div> </body></html>