ol_scale_fill_continuous: Fill Color Scale (Continuous)

View source: R/scales.R

ol_scale_fill_continuousR Documentation

Fill Color Scale (Continuous)

Description

Specify a continuous fill color mapping scale.

Usage

ol_scale_fill_continuous(low.val, high.val, low.col = NULL,
  high.col = NULL, rotate.clockwise = TRUE, name = NULL,
  na.col.val = "#FFFFFF00", opacity = 1, preserve.opacity = FALSE,
  display = FALSE)

Arguments

low.val

numeric the minimum variable value to be mapped to the lowest color.

high.val

numeric the maximum variable value to be mapped to the highest color.

low.col

character the "low" color.

high.col

character the "high" color.

rotate.clockwise

logical. If TRUE, continuous scale will map to colors on a clockwise rotation from low.col to high.col on the hue-saturation-value (HSV) color space. If FALSE, rotation will be counter-clockwise.

name

character the scale name.

na.col.val

character the color assigned to non-numeric or NA values.

opacity

numeric in [0,1]. The fill opacity, if not specified in the low.col and high.col colors.

preserve.opacity

logical indicating whether to draw the legend with the same opacity as the feature fills on the map.

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.

Details

This method maps OpenLayers feature fill colors to continuous variable values. This scale can be added to an Ol.Map S3 object only if the Ol.Map object has a layer with a "fill" mapping to a numeric variable. If no such layer exists, attempts to add this type of scale will result in a warning. Attempts to add this scale to a discrete variable mapping will throw an error.

Value

list of class Scale.Fill.Continuous.

See Also

ol_map, ol_geom_polygon, ol_geom_circle

Examples

polygon.matrix1 <- matrix(
    c(
        -80.385+c(0,0.05,0.05,0,0),
        25.782618+c(0,0,0.05,0.05,0)
    ),
    ncol=2
)
polygon.matrix2 <- matrix(
    c(
        -80.34+c(0,0.05,0.025,0),
        25.73++c(0,0,0.025*sqrt(3),0)
    ),
    ncol=2
)
polygon.list<-list(polygon.matrix1,polygon.matrix2)
polygon.df <- data.frame(shape=c("rectangle","triangle"),no=runif(2))
miami.OSM.basemap <- ol_map(
    center=c(-80.385790,25.782618),
    zoom=9
    ) + 
   streetmap() 
polygon.layer <- ol_geom_polygon(
    polygon.list,
    mapping=ol_aes(
        fill=no #numeric mapping
    ),
    df=polygon.df,
    lwd=1,
    name="Miami Polygons",
    toggle.control=TRUE,
    tooltip=polygon.df$no
)
polygon.fill.scale <- ol_scale_fill_continuous(
    low.val=0,
    high.val=1,
    low.col='red',
    high.col='green',
    opacity=0.5,
    preserve.opacity=FALSE,
    display=TRUE
)
polygons.over.miami <- miami.OSM.basemap + 
    polygon.layer + 
    polygon.fill.scale

## Not run: 
# Output to file and view
ol_map2HTML(
  polygons.over.miami,
  'miami_polygons.html',
  map.heading="Miami Shapes",
  map.note="Note: Mouseover popup values are 
    independent of shape size &amp; color."
)
browseURL("miami_polygons.html")

## End(Not run)

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