Learn R Programming

gstat (version 2.1-0)

image: Image Gridded Coordinates in Data Frame

Description

Image gridded data, held in a data frame, keeping the right aspect ratio for axes, and the right cell shape

Usage

# S3 method for data.frame
image(x, zcol = 3, xcol = 1, ycol = 2, asp = 1, ...)
xyz2img(xyz, zcol = 3, xcol = 1, ycol = 2, tolerance = 10 * .Machine$double.eps)

Value

image.data.frame plots an image from gridded data, organized in arbritrary order, in a data frame. It uses xyz2img and image.default for this. In the S-Plus version, xyz2img

tries to make an image object with a size such that it will plot with an equal aspect ratio; for the R version, image.data.frame uses the asp=1 argument to guarantee this.

xyz2img returns a list with components: z, a matrix containing the z-values; x, the increasing coordinates of the rows of z; y, the increasing coordinates of the columns of z. This list is suitable input to image.default.

Arguments

x

data frame (or matrix) with x-coordinate, y-coordinate, and z-coordinate in its columns

zcol

column number or name of z-variable

xcol

column number or name of x-coordinate

ycol

column number or name of y-coordinate

asp

aspect ratio for the x and y axes

...

arguments, passed to image.default

xyz

data frame (same as x)

tolerance

maximum allowed deviation for coordinats from being exactly on a regularly spaced grid

Author

Edzer Pebesma

Examples

Run this code
library(sp)
data(meuse)
data(meuse.grid)
g <- gstat(formula=log(zinc)~1,locations=~x+y,data=meuse,model=vgm(1,"Exp",300))
x <- predict(g, meuse.grid)
image(x, 4, main="kriging variance and data points")
points(meuse$x, meuse$y, pch = "+")

Run the code above in your browser using DataLab