ol_scale_lty_discrete: Line Type Scale (Experimental)

View source: R/scales.R

ol_scale_lty_discreteR Documentation

Line Type Scale (Experimental)

Description

Specify a discrete line type mapping scale.

Usage

ol_scale_lty_discrete(lty.list = NULL, name = NULL, na.lty.val = NA,
  ordered.values = NULL, opacity = 1, draw.color = "black",
  draw.lwd = 1, display = FALSE)

Arguments

lty.list

numeric named list of the form list(value=numeric.vector). If NULL, a default line type mapping is assigned. The input vectors will be converted to javascript numeric arrays. See the lineDash propery in the OpenLayers Stroke Documentation for interpretation of these inputs.

name

character the scale name.

na.lty.val

numeric the lineDash vector assigned to unrecognized or NA values.

ordered.values

character, numeric, or factor vector containing the ordered unique discrete variable values. This input is used to determine the order of the values appearing in the legend. If not supplied, the order is taken from names(lwd.vector).

opacity

numeric in [0,1]. The line opacity used in the legend only.

draw.color

character color used in the legend lines only.

draw.lwd

numeric indicating the line width for the legend only. This will be passed to an R plot command. See par.

display

logical indicating whether to draw the scale for output in the HTML. If TRUE, a bitmap will be created and sourced in the HTML in an img tag. If FALSE, the draw.* inputs are ignored.

Details

This method maps OpenLayers feature line dash types to discrete variable values. This scale can be added to an Ol.Map S3 object only if the Ol.Map object has a layer with a "lty" mapping to a numeric, character, or factor type variable. If no such layer exists, attempts to add this type of scale will result in a warning. The lty.list input enables the user to specify the exact mapping, assigning line dash types to specific variable values. The lty aesthetic does not have a continuous scale.

Note: this method does not result in consistant rendering for different browsers or map zoom levels.

Value

list of class Scale.Lwd.Discrete.

See Also

ol_map, ol_geom_polygon, ol_geom_line

Examples

line.matrix1 <- matrix(
    c(
        -80.4,-80.4,
        25.78,25.88
    ),
    ncol=2
)
line.matrix2 <- matrix(
    c(
        -80.25,-80.35,
        25.65,25.65
    ),
    ncol=2
)
line.list <- list(line.matrix1,line.matrix2)
line.df <- data.frame(
    direction=c("vertical","horizontal"),
    no=runif(2)
)
miami.gray.basemap <- ol_map(
    center=c(-80.385790,25.782618),
    zoom=9
    ) + 
   lightgray() 
line.layer <- ol_geom_line(
    line.list,
    mapping=ol_aes(
        lty=direction # discrete mapping
    ),
    df=line.df,
    name="Miami Lines",
    toggle.control=TRUE
)
line.type.scale <- ol_scale_lty_discrete(
    lty.list=list(
        vertical = 1,
        horizontal = c(5,5)
    ),
    name="Direction",
    display=TRUE
)
line.map.miami <- miami.gray.basemap + 
    line.layer + 
    line.type.scale
## Not run: 
# Output to file and view
ol_map2HTML(
  line.map.miami,
  'miami_lines.html',
  map.heading="Miami Lines"
)
browseURL("miami_lines.html")

## End(Not run)

cemarks/ROpenLayers documentation built on March 31, 2022, 12:05 p.m.