| ol_scale_size_discrete | R Documentation |
Specify a discrete size mapping for a point layer.
ol_scale_size_discrete(size.vector = NULL, name = NULL, na.size.val = 0.33, draw.fill = NULL, legend.breaks = NULL, display = FALSE)
size.vector |
numeric named vector of the form
|
name |
character scale name. |
na.size.val |
numeric the size scalar assigned to unrecognized or NA values. |
draw.fill |
character fill color for drawing points in the legend only. |
legend.breaks |
numeric ordered vector of variable values to display in the legend. |
display |
logical indicating whether to draw the scale for output
in the HTML. If |
This method maps OpenLayers point feature sizes to a discrete set of variable values. This scale can be added to an Ol.Map S3 object only if the Ol.Map object has a layer with a "size" mapping to a numeric, character, or factor variable. If no such layer exists, attempts to add this type of scale will result in a warning.
Size inputs to this method are applied as scalars to the icon widths. A size value of 1 translates to an icon width of 40 pixels for "pin" markers, or 20 pixels for "dot" markers.
list of class Scale.Size.Discrete.
ol_map,
ol_geom_point,
point.matrix <- matrix(
c(
-80.885+runif(10),
25.223+runif(10)
),
ncol=2
)
point.df <- data.frame(
pt.type=sample(c("A","B"),10,replace=TRUE),
pt.numeric=runif(10)*10
)
miami.points.map <- ol_map(
center=c(-80.385790,25.782618),
zoom=10
) +
streetmap()+
ol_geom_point(
point.matrix,
df=point.df,
mapping=ol_aes(
size=pt.type # continuous mapping
),
name="Point",
marker="pin",
fill='green',
toggle.control=TRUE,
tooltip=point.df$pt.type
) +
ol_scale_size_discrete(
c(A=1,B=0.5),
name="Point Type",
draw.fill='black',
display=TRUE
)
## Not run:
# Oave to file and open on browser
ol_map2HTML(
miami.points.map,
'pointsizes.html'
)
browseURL('pointsizes.html')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.