Map of simple features in leaflet that is coloured.
leaf_sf_col(
data,
col_var,
label_var = NULL,
popup = TRUE,
popup_vars_vctr = NULL,
popup_numeric_format = function(x) prettyNum(x, big.mark = "", scientific = FALSE),
popup_vars_rename = snakecase::to_sentence_case,
pal = NULL,
pal_na = "#7F7F7F",
pal_rev = FALSE,
alpha_point = NULL,
alpha_line = NULL,
alpha_fill = NULL,
size_point = 2,
size_line = 2,
basemap = "light",
col_breaks_n = 4,
col_cuts = NULL,
col_intervals_left = TRUE,
col_labels = NULL,
col_legend_none = FALSE,
col_method = NULL,
col_na_rm = FALSE,
col_title = NULL,
label_numeric_format = function(x) prettyNum(x, big.mark = ",", scientific = FALSE),
layer_id_var = NULL,
group_id = NULL,
legend_id = NULL,
map_id = "leaf"
)
An sf object of geometry type point/multipoint, linestring/multilinestring or polygon/multipolygon geometry type. Required input.
Unquoted variable to colour the features by. Required input.
Unquoted variable to label the features by. If NULL, defaults to using the colour variable.
TRUE or FALSE of whether to have a popup.
Vector of quoted variable names to include in the popup. If NULL, defaults to making a leafpop::popupTable of all columns.
A function to format all numeric variables within the popup column. Defaults to non-scientific. Use function(x) x to leave as is.
Function to rename column names for the popup. Defaults to snakecase::to_sentence_case. Use function(x) x to leave column names untransformed.
Character vector of hex codes.
The hex code or name of the NA colour to be used.
Reverses the palette. Defaults to FALSE.
The opacity of the points.
The opacity of the outline.
The opacity of the fill.
Size of points (i.e. radius). Defaults to 2.
Size of lines around features (i.e. weight). Defaults to 2.
The underlying basemap. Either "light", "dark", "satellite", "street", or "ocean". Defaults to "light". Only applicable where shiny equals FALSE.
For a numeric colour variable, the desired number of intervals on the colour scale.
A vector of cuts to colour a numeric variable. If "bin" is selected, the first number in the vector should be either -Inf or 0, and the final number Inf. If "quantile" is selected, the first number in the vector should be 0 and the final number should be 1. Defaults to quartiles.
For a numeric colour variable, TRUE or FALSE of whether bins or quantiles are to be cut left-closed. Defaults to TRUE.
A function or named vector to modify the colour scale labels. Defaults to snakecase::to_sentence_case if categorical, and scales::label_comma() if numeric. Use function(x) x to keep labels untransformed.
TRUE or FALSE of whether to remove the legend.
The method of colouring features, either "bin", "quantile", "continuous", or "category." If numeric, defaults to "bin".
TRUE or FALSE of whether to include col_var NA values. Defaults to FALSE.
A title string that will be wrapped into the legend.
A function to format the numeric labels. Defaults to adding a comma seperator. Use function(x) x to leave as is.
Unquoted variable to be used in shiny, so that in the event where a feature is clicked on, the value of this is returned for that feature (e.g. input$map_marker_click$id).
The id name for the sf group.
The id name for the layerId of the legend.
The map id for the leaflet map. Defaults to "leaf".
A leaflet object.
if (FALSE) {
leaf_sf_col(example_point,
col_var = trend_category)
leaf_sf_col(example_polygon,
col_var = density)
leaf_sf_col(example_polygon,
col_var = density,
col_method = "bin",
col_breaks_n = 5)
leaf_sf_col(example_polygon,
col_var = density,
col_method = "bin",
col_cuts = c(0, 10, 50, 100, 150, 200, Inf))
leaf_sf_col(example_polygon,
col_var = density,
col_method = "quantile",
col_breaks_n = 4)
leaf_sf_col(example_polygon,
col_var = density,
col_method = "quantile",
col_cuts = c(0, 0.25, 0.5, 0.75, 0.95, 1))
}