map.hatching: Map hatching

View source: R/map.hatching.R

map.hatchingR Documentation

Map hatching

Description

Utility for map hatching, following IPCC convention or other user-defined specifications.

Usage

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,
  ...
)

Arguments

clim

A climate4R climatology

threshold

Pixel threshold value to differentiate hatched/unhatched areas

condition

Inequality to be applied as condition. Accepted values are "GT", "GE", "LT", "LE", meaning respectively (strictly) greater than, greater or equal than, (strictly) lower than and lower or equal than.

invert

Default to FALSE and unused. For convenience, this flag inverts the selection so the specified map values are NOT hatched, and the other way round.

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 times argument in function upscaleGrid.

angle

Angle of the hatching lines w.r.t. the horizontal line, as character string. Possible values are "-45" (default) and "45" degrees.

upscaling.aggr.fun

Function performing the spatial aggregation when upscaling according to parameter density. The default uses the average value.

coverage.percent

Coverage percent

...

Graphical parameters affecting the appearance of the hatching lines. See details and examples.

Details

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.

Value

A graphical parameter list to be superposed onto the climatological map via sp.layout

Note

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

Author(s)

J. Bedia, M. Iturbide

Examples



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))



SantanderMetGroup/visualizeR documentation built on Oct. 28, 2023, 6:11 a.m.