Description Usage Arguments Value Author(s) References See Also Examples
Draw a map of raster data and geographical features. A key showing how the colors map to raster values is shown below the map. The width and height of the graphics region will be automagically determined in some cases.
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 | PlotMap(
r,
layer = 1,
att = NULL,
n = NULL,
breaks = NULL,
xlim = NULL,
ylim = NULL,
zlim = NULL,
asp = NULL,
extend.xy = FALSE,
extend.z = FALSE,
reg.axs = TRUE,
dms.tick = FALSE,
bg.lines = FALSE,
bg.image = NULL,
bg.image.alpha = 1,
pal = NULL,
col = NULL,
max.dev.dim = c(43, 56),
labels = NULL,
scale.loc = NULL,
arrow.loc = NULL,
explanation = NULL,
credit = NULL,
shade = NULL,
contour.lines = NULL,
rivers = NULL,
lakes = NULL,
roads = NULL,
draw.key = NULL,
draw.raster = TRUE,
file = NULL,
close.file = TRUE,
useRaster,
simplify
)
|
r |
'Raster*', 'Spatial*', or 'CRS'. Object that can be converted to a raster layer, or coordinate reference system (CRS). |
layer |
'integer' count.
Layer to extract from if |
att |
'integer' count or 'character' string.
Levels attribute to use in the Raster Attribute Table (RAT);
requires |
n |
'integer' count.
Desired number of intervals to partition the range of raster values (or |
breaks |
'numeric' vector. Break points used to partition the colors representing numeric raster values (optional). |
xlim |
'numeric' vector of length 2. Minimum and maximum values for the x-axis. |
ylim |
'numeric' vector of length 2. Minimum and maximum values for the y-axis. |
zlim |
'numeric' vector of length 2. Minimum and maximum raster values for which colors should be plotted. |
asp |
'numeric' number.
y/x aspect ratio for spatial axes.
Defaults to 1 (one unit on the x-axis equals one unit on the y-axis) when |
extend.xy |
'logical' flag. If true, the spatial limits will be extended to the next tick mark on the axes beyond the grid extent. |
extend.z |
'logical' flag.
If true, the raster value limits will be extended to the next tick mark on the color key beyond the measured range.
Not used if the |
reg.axs |
'logical' flag. If true, the spatial data range is extended. |
dms.tick |
'logical' flag.
If true and |
bg.lines |
'logical' flag. If true, grids or graticules are drawn in back of the raster layer using white lines and a grey background. |
bg.image |
'RasterLayer'.
An image to be drawn in back of the main raster layer |
bg.image.alpha |
'numeric' number. Opacity of the background image from 0 to 1. |
pal |
'function'. Color palette to be used to assign colors in the plot. |
col |
'character' vector.
Colors to be used in the plot.
This argument requires |
max.dev.dim |
'numeric' vector of length 2, value is recycled as necessary.
Maximum width and height for the graphics device in picas, respectively.
Where 1 pica is equal to 1/6 of an inch, 4.2333 of a millimeter, or 12 points.
Suggested dimensions for single-column, double-column, and side title figures are
|
labels |
'list'.
Location and values of labels in the color key.
This list may include components |
scale.loc |
'character' string.
Position of the scale bar in the main plot region;
see |
arrow.loc |
'character' string.
Position of the north arrow in the main plot region;
see |
explanation |
'character' string. Label explaining the raster cell value. |
credit |
'character' string. Label crediting the base map. |
shade |
'list'.
If specified, a semi-transparent shade layer is drawn on top of the raster layer.
This layer is described using a list of arguments supplied to the
|
contour.lines |
'list'.
If specified, contour lines are drawn.
The contours are described using a list of arguments supplied to the |
rivers |
'list'.
If specified, lines are drawn.
The lines are described using a list of arguments supplied to the plot method for
class ' |
lakes |
'list'.
If specified, polygons are drawn.
The polygons are described using a list of arguments supplied to the plot method for
class ' |
roads |
'list'.
If specified, lines are drawn.
The lines are described using a list of arguments supplied to the plot method for
class ' |
draw.key |
'logical' flag. Whether a color key should be drawn. |
draw.raster |
'logical' flag. Whether the raster image should be drawn. |
file |
'character' string. Name of the output file. Specifying this argument will start a graphics device driver for producing a PDF or PNG file format—the file extension determines the format type. The width and height of the graphics region will be automagically determined and included with the function's returned values, see "Value" section for details; these device dimensions can be useful when creating similar map layouts in dynamic reports. |
close.file |
'logical' flag.
Whether the graphics device driver should be shut down after the function exits.
Unused if |
useRaster |
'logical' flag.
If true, a bitmap raster is used to plot |
simplify |
'numeric' number.
Specifying this argument will convert the raster |
A 'list' with the following graphical parameters:
device dimensions c(width, height)
, in inches.
extremes of the coordinates of the plotting region c(x1, x2, y1, y2)
.
relative heights on the device c(upper, lower)
for the map and color-key plots.
J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center
Douglas, D., and Peucker, T., 1961, Algorithms for the reduction of the number of points required to represent a digitized line or its caricature: The Canadian Cartographer, v. 10, no. 2, p. 112–122.
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | r <- raster::raster(nrow = 10, ncol = 10, crs = NA)
r[] <- 1L
r[51:100] <- 2L
r[3:6, 1:5] <- 8L
r <- raster::ratify(r)
rat <- cbind(raster::levels(r)[[1]],
land.cover = c("Pine", "Oak", "Meadow"))
levels(r) <- rat
PlotMap(r)
data(meuse, meuse.grid, package = "sp")
sp::coordinates(meuse.grid) <- ~x+y
sp::proj4string(meuse.grid) <- sp::CRS("+init=epsg:28992")
sp::gridded(meuse.grid) <- TRUE
meuse.grid <- raster::raster(meuse.grid, layer = "soil")
model <- gstat::gstat(id = "zinc", formula = zinc~1,
locations = ~x+y, data = meuse)
r <- raster::interpolate(meuse.grid, model)
r <- raster::mask(r, meuse.grid)
Pal <- function(n) GetColors(n, stops=c(0.3, 0.9))
breaks <- seq(0, 2000, by = 200)
credit <- paste("Data collected in a flood plain of the river Meuse,",
"near the village of Stein (Netherlands),",
"\nand iterpolated on a grid with 40m by 40m spacing",
"using inverse distance weighting.")
PlotMap(r, breaks = breaks, pal = Pal, dms.tick = TRUE,
bg.lines = TRUE, contour.lines = list("col" = "#1F1F1F"),
credit = credit, draw.key = FALSE, simplify = 0)
AddScaleBar(unit = c("KILOMETER", "MILES"),
conv.fact = c(0.001, 0.000621371),
loc = "bottomright", inset = c(0.1, 0.05))
AddGradientLegend(breaks, Pal, at = breaks,
title = "Topsoil zinc\nconcentration\n(ppm)",
loc = "topleft", inset = c(0.05, 0.1),
strip.dim = c(2, 20))
m <- datasets::volcano
m <- m[nrow(m):1, ncol(m):1]
x <- seq(from = 2667405, length.out = ncol(m), by = 10)
y <- seq(from = 6478705, length.out = nrow(m), by = 10)
r <- raster::raster(m, xmn = min(x), xmx = max(x), ymn = min(y),
ymx = max(y), crs = "+init=epsg:27200")
bg.image <- raster::hillShade(raster::terrain(r, "slope"),
raster::terrain(r, "aspect"))
credit <- paste("Digitized from a topographic map by Ross Ihaka",
"on a grid with 10-meter by 10-meter spacing.")
explanation <- "Elevation on Auckland's Maunga Whau volcano, in meters."
PlotMap(r, extend.z = TRUE, bg.image = bg.image,
pal = GetColors(scheme = "DEM screen", alpha = 0.8),
scale.loc = "bottomright", arrow.loc = "topright",
explanation = explanation, credit = credit,
contour.lines = list("col" = "#1F1F1FA6"), "useRaster" = TRUE)
out <- PlotMap(r, file = "Rplots1.pdf")
print(out)
pdf(file = "Rplots2.pdf", width = out$din[1], height = out$din[2])
PlotMap(r)
raster::contour(r, col = "white", add = TRUE)
dev.off()
file.remove(c("Rplots1.pdf", "Rplots2.pdf"))
graphics.off()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.