PlotRaster: Create a Filled Contour Plot of Spatial Data

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/PlotRaster.R

Description

Raster plot for spatial data with attributes.

Usage

1
2
3
4
5
PlotRaster(grd, zcol, pts, ply, net.idxs, rm.idxs, xlim, ylim, at,
           pal = heat.colors, contour = FALSE, label.contours = FALSE,
           label.pts = FALSE, main = "", gr.type = "windows",
           gr.file = NULL, width = 7, height = NA, lo = list(),
           ll.lines = FALSE)

Arguments

grd

SpatialGridDataFrame; the raster data.

zcol

character; the z-variable column name or number in attribute table of grd.

pts

SpatialPointsDataFrame; the point coordinates to include in layout.

ply

SpatialPolygonsDataFrame; a polygon defining the spatial domain of the raster data; data outside this domain is excluded. Polygon is included in the layout.

net.idxs

integer; a vector of row indexes in pts, point coordinates at these sites are drawn as circle symbols with white backgrounds. All other circle symbols are drawn with gray backgrounds.

rm.idxs

integer; a vector of row indexes in pts, point symbols at these sites are drawn as crosses.

xlim

numeric; a vector of length 2 giving left and right limits for the x-axis.

ylim

numeric; a vector of length 2 giving lower and upper limits for the y-axis.

at

numeric; a vector giving breakpoints along the range of z (including upper and lower limits).

pal

function; a color palette to be used to assign colors in the plot.

contour

logical; whether to add contour lines to plot, default is FALSE.

label.contours

logical; whether to label contour lines, default is FALSE.

label.pts

character or logical; the attribute in pts specifying the labels to place at point coordinates. If TRUE, points are labeled with index numbers.

main

character; the main plot title to be placed on top.

gr.type

character; the name of a graphics driver, either "postscript", "pdf", "png", or the default "windows".

gr.file

character; the path of a file for writing the graphics, only used if gr.type is not "windows".

width, height

numeric; the (nominal) width and height of the canvas of the plotting window in inches.

lo

list; a list with more layout items, see sp.layout argument in spplot.

ll.lines

logical; whether to plot longitude-latitude grid over projected data, default is FALSE.

Details

Spatial data is transformed to the map projection and datum of the raster data set, grd.

Value

Returns (or plots) the raster plot.

Author(s)

J.C. Fisher

See Also

spplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
data(ESRP_NED)
data(ESRP_NWIS)
data(ESRP_Boundary)
data(ESRP_Lakes)
data(ESRP_Rivers)
data(INL_Boundary)

# Plot topography
PlotRaster(ESRP_NED, "var2")

# Set axis limits, add points and long-lat grid to plot layout
pts <- ESRP_NWIS[ESRP_NWIS$network.nm == "State", ]
xlim <- c(10000, 328000)
ylim <- c(81200, 335700)
PlotRaster(ESRP_NED, "var2", pts, ESRP_Boundary, xlim = xlim, ylim = ylim,
           pal = terrain.colors, label.pts = "map.no", ll.lines = TRUE)

# Plot hill shade, add lakes, river, and INL boundary to the plot layout
slp <- terrain(raster(ESRP_NED), opt = "slope")
asp <- terrain(raster(ESRP_NED), opt = "aspect")
grd <- as(hillShade(slp, asp, 40, 270), "SpatialGridDataFrame")
zlim <- range(grd[[1]], na.rm = TRUE)
at <- seq(zlim[1], zlim[2], length.out = 50)
pal <- function(n) grey(0:50 / 50)[1:n]
lo <- list()
lo[[1]] <- list("sp.polygons", ESRP_Lakes, col = "#1B70E0", fill = "#BAE4E5",
                first = FALSE)
lo[[2]] <- list("sp.lines", ESRP_Rivers, col = "#1B70E0", first = FALSE)
lo[[3]] <- list("sp.polygons", INL_Boundary, col = "#000000", first = FALSE)
PlotRaster(grd, 1, xlim = xlim, ylim = ylim, at = at, pal = pal, lo = lo)

# Set new axis limits
pts <- ESRP_NWIS[ESRP_NWIS$network.nm == "INL", ]
xlim <- c(178000, 257500)
ylim <- c(202000, 272000)
PlotRaster(ESRP_NED, "var2", pts, ESRP_Boundary, xlim = xlim, ylim = ylim,
           pal = terrain.colors, ll.lines = TRUE, contour = TRUE)

jfisher-usgs/ObsNetwork documentation built on Jan. 3, 2020, 4:35 p.m.