Description Usage Arguments Details Value Author(s) See Also Examples
Creates a categorized style based on an attribute
1 2 |
prop |
Property (attribute) of the data to be styled, as string. |
val |
A vector giving the data values to be used as categories. |
style.val |
Styling values, a vector of colors or radii applied to the categories given by |
leg |
Legend title as string. The line break sequence |
... |
Additional styling parameters, see |
If val
does not cover all data values, the unspecified data values are colored gray. By adding an extra color for unspecified data values to style.val
, an "other"-category is shown in the legend.
A categorized style object.
Christian Graul
styleSingle
, styleGrad
, leaflet
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | ## Not run:
# prepare data
dat <- system.file(package="leafletR", "files", "park_sk.geojson")
# simple categorizing
sty <- styleCat(prop="lynx", val=c("yes", "no"),
style.val=c("green", "red"), leg="Lynx occurrence")
map <- leaflet(data=dat, dest=tempdir(), title="Lynx",
style=sty)
# just one category
sty <- styleCat(prop="wisent", val="yes", style.val="red",
leg="Wisent occurrence")
map <- leaflet(data=dat, dest=tempdir(), title="Wisent",
style=sty)
# get nice colors using ColorBrewer
require(RColorBrewer)
pal <- brewer.pal(7, "Dark2")
sty <- styleCat(prop="year", val=c("1949", "1967", "1978", "1988",
"1997", "1998", "2002"), style.val=pal, leg="established:\n")
map <- leaflet(data=dat, dest=tempdir(),
title="National parks", style=sty)
# add 'other'-category to legend
require(RColorBrewer)
pal <- brewer.pal(7, "Dark2")
sty <- styleCat(prop="year", val=c("1997", "1998", "2002"),
style.val=pal, leg="established:\n")
map <- leaflet(data=dat, dest=tempdir(),
title="National parks", style=sty)
# additional styling parameters
sty <- styleCat(prop="brown_bear", val=c("yes", "no"),
style.val=c("darkgreen", "red"), leg="Brown bear\noccurrence",
alpha=1, lwd=4, fill=NA)
map <- leaflet(data=dat, dest=tempdir(), title="Brown bear",
style=sty)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.