map.hatching | R Documentation |
Utility for map hatching, following IPCC convention or other user-defined specifications.
map.hatching(
clim,
threshold = 0.05,
condition = "LT",
invert = FALSE,
density = 4,
angle = "-45",
upscaling.aggr.fun = list(FUN = "mean", na.rm = TRUE),
coverage.percent = 100,
...
)
clim |
A climate4R |
threshold |
Pixel threshold value to differentiate hatched/unhatched areas |
condition |
Inequality to be applied as condition. Accepted values are |
invert |
Default to |
density |
Density of the hatching pattern. This parameter is related to the spatial resolution of the input grid. Default to 4,
so hatching lines are sepparated in the X axis by a distance of four times the X-resolution of the input grid. Passed to |
angle |
Angle of the hatching lines w.r.t. the horizontal line, as character string. Possible values are |
upscaling.aggr.fun |
Function performing the spatial aggregation when upscaling according to parameter |
coverage.percent |
Coverage percent |
... |
Graphical parameters affecting the appearance of the hatching lines. See details and examples. |
The function follows the same philosophy as other graphical helpers implemented in visualizeR, namely
map.stippling
and map.lines
, thus allowing for a flexible definition
of graphical layers to be added onto a climatological map using the lattice plot methods used by spatialPlot
.
Several details on its application are illustrated in the examples below.
A graphical parameter list to be superposed onto the climatological map via sp.layout
The function assumes that a valid CRS is in use, so no mismatches between the hatched area and
the base climatology happen. See projectGrid
for details
J. Bedia, M. Iturbide
library(visualizeR)
require(transformeR)
data(tas.ncep)
# The climatology of DJF 2m air temperature (NCEP reanalysis 1983-2010) is calculated
# as example:
clim <- climatology(tas.ncep)
attr(clim$xyCoords, "projection") <- NA
spatialPlot(clim, backdrop.theme = "coastline", rev.colors = TRUE)
# Basic usage
# In this example, the hatching will apply over all world areas whose temperature
# is above 27.5:
l1 <- map.hatching(clim, threshold = 25.5, condition = "GT")
spatialPlot(clim, backdrop.theme = "coastline", rev.colors = TRUE, sp.layout = list(l1))
# Inverted selection:
l2 <- map.hatching(clim, threshold = 25.5, condition = "GT", invert = TRUE)
spatialPlot(clim, backdrop.theme = "coastline", rev.colors = TRUE,
sp.layout = list(l2), invert = TRUE)
# Hatching density
# The argument 'density' controls the line density. It is proportional to the spatial
# resolution of the underlying climatology. For instance, density = 4 (the default value)
# means that lines are horizontally sepparated by a distance of four pixels.
l3 <- map.hatching(clim, threshold = 25.5, condition = "GT", density = 2)
spatialPlot(clim, backdrop.theme = "coastline", rev.colors = TRUE, sp.layout = list(l3))
# Hatching orientation
# The hatching lines ca be drawn following 45 instead of -45 degrees:
l4 <- map.hatching(clim, threshold = 25.5, condition = "GT", density = 2, angle = "45")
spatialPlot(clim, backdrop.theme = "coastline", rev.colors = TRUE, sp.layout = list(l4))
# Controlling hatching lines appearance:
# These are typically related to line type (lty), line width (lwd), line color (col) and so on.
# These are to map.hatching via ellipsis:
l5 <- map.hatching(clim, threshold = 25.5, condition = "GT",
density = 2, angle = "45", lwd = 1.5, col = "green", lty = 2)
spatialPlot(clim, backdrop.theme = "coastline", rev.colors = TRUE, sp.layout = list(l5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.