| ol_scale_fill_continuous | R Documentation |
Specify a continuous fill color mapping scale.
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)
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 |
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 |
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 |
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.
list of class Scale.Fill.Continuous.
ol_map,
ol_geom_polygon,
ol_geom_circle
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 & color."
)
browseURL("miami_polygons.html")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.