spatialPlot | R Documentation |
A wrapper for the lattice (trellis) plot methods for spatial data in sp::spplot
spatialPlot(
grid,
backdrop.theme = "none",
set.min = NULL,
set.max = NULL,
lonCenter = NULL,
color.theme = "RdYlBu",
rev.colors = FALSE,
...
)
grid |
Input grid |
backdrop.theme |
Reference geographical lines to be added to the plot. See Details. |
set.min |
Numeric value indicating an absolute minimum value (default to |
set.max |
Same as |
lonCenter |
Value of the longitude to be centered in the plot (between 0 and 180). |
color.theme |
A character string indicating the color theme to use in the map.
Valid values are those available in the |
rev.colors |
Should the chosen color theme be reversed? (default to |
... |
Further arguments passed to |
The function applies the spplot
method after conversion of the climatological map(s) to a
SpatialGridDataFrame
.
The set.min
and set.max
options are useful in order to preserve adequate ranges for map representation,
avoiding the influence of extreme values. Note that this is different than setting a range of values with an
interval using the at
argument. The latter choice, that overrides set.min
and set.max
,
leaves blank grid points for outlying values.
Multigrids
Multigrids of climatologies can be created using makeMultiGrid
for trellis visualization of different variables, or for instance, for the comparison of
raw and corrected/downscaled scenarios side to side. In case of multimember multigrids,
the function will internally compute the ensemble mean of each variable in the multigrid
for representation (with a message).
Backdrop theme
Current implemented options are "none"
and "coastline"
, which contains
a simplied vector theme delineating the world coastlines. Any other themes can be introduced
by the user using the sp.layout
options in spplot
.
Controlling graphical parameters
Many different aspects of the map can be controlled passing the relevant arguments to
spplot
. Fine control of graphical parameters for the trellis display can
be also controlled using trellis.par.set
.
Some examples of specific map graphical options are available in the help of function spplot
.
In addtion, fine-tuning of the resulting plots can be obtained using the arguments of lattice plots. For
an overview, see the help of function xyplot
.
As spplot, spatialPlot
returns a lattice plot of class “trellis”.
If you fail to “see” it, explicitly call print(spatialPlot(...))
.
J. Bedia
Bivand, R.S., Pebesma, E.J., Gomez-Rubio, V., 2013. Applied Spatial Data Analysis with R, 2nd ed, useR! Springer, NY.
For some graticulate customization examples, visit the sp Gallery: https://edzer.github.io/sp/
climatology
for details on climatology calculation.
map.stippling
, for adding a custom point layer on top of the map.
map.lines
, to add lines and polygons to climatological maps
Also see spplot
in package sp for further information on plotting capabilities and options
require(transformeR)
require(climate4R.datasets)
require(sp)
data("CFS_Iberia_tas")
# Climatology is computed:
clim <- climatology(CFS_Iberia_tas, by.member = TRUE)
spatialPlot(clim)
# Geographical lines can be added using the argument 'backdrop.theme':
spatialPlot(clim, backdrop.theme = "coastline")
spatialPlot(clim, backdrop.theme = "countries")
# Further arguments can be passed to 'spplot'...
# ... a subset of members to be displayed, using 'zcol':
spatialPlot(clim,
backdrop.theme = "coastline",
zcol = 1:4)
# ... regional focuses (e.g. Portugal).
spatialPlot(clim,
backdrop.theme = "countries",
xlim = c(-10,-6), ylim = c(36,43),
zcol = 1:4,
scales = list(draw = TRUE))
# Changing the default color palette and ranges:
# Reverse colors (so blue is colder)
spatialPlot(clim,
backdrop.theme = "coastline",
zcol = 1:4, rev.colors = TRUE)
# Use a different theme from RColorBrewer
require(RColorBrewer)
display.brewer.all()
spatialPlot(clim,
backdrop.theme = "coastline",
zcol = 1:4,
color.theme = "BrBG")
# Or 'jet.colors'
spatialPlot(clim,
backdrop.theme = "coastline",
zcol = 1:4,
color.theme = "jet.colors")
# Or any other custom palette via 'col.regions'
spatialPlot(clim,
backdrop.theme = "coastline",
zcol = 1:4,
col.regions = cm.colors(27), at = seq(0,17,1))
# For ensemble means climatology should be called with 'by.member' set to FALSE:
clim <- climatology(CFS_Iberia_tas, by.member = FALSE)
# Adding contours to the plot is direct with argument 'contour':
spatialPlot(clim,
scales = list(draw = TRUE),
contour = TRUE,
main = "tas Predictions July Ensemble Mean")
## Example of multigrid plotting
data("NCEP_Iberia_psl")
## Winter data are split into monthly climatologies
monthly.clim.grids <- lapply(getSeason(NCEP_Iberia_psl), function(x) {
climatology(subsetGrid(NCEP_Iberia_psl, season = x))
})
## Skip the temporal checks, as grids correspond to different time slices
mg <- do.call("makeMultiGrid",
c(monthly.clim.grids, skip.temporal.check = TRUE))
## We change the panel names
spatialPlot(mg,
backdrop.theme = "coastline",
names.attr = c("DEC","JAN","FEB"),
main = "Mean PSL climatology 1991-2010",
scales = list(draw = TRUE), rev.colors = TRUE)
# Station data:
data("VALUE_Iberia_pr")
spatialPlot(climatology(VALUE_Iberia_pr),
backdrop.theme = "countries",
color.theme = "BrBG",
rev.colors = TRUE, cex = 2.5)
# Station data (hatching):
data("VALUE_Iberia_pr")
# Just as an example, stations with a precip climatology lower than 3mm/day
ind <- which(climatology(VALUE_Iberia_pr)$Data < 3)
spatialPlot(climatology(VALUE_Iberia_pr),
backdrop.theme = "countries",
colorkey = TRUE,
sp.layout = list(list("sp.points",
SpatialPoints(VALUE_Iberia_pr$xyCoords[ind,]), pch = 4, cex = 1.5,
first = FALSE, col = "black")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.