A set of nifty palettes and functions for maps designed by the DiSARM team at UCSF
library(devtools)
install_github("disarm-platform/MapPalettes")
library(MapPalettes)
view_palette("green_machine", n=64, type = "raster")
library(leaflet) # for colorNumeric function
data("swz_elev")
hexbins <- hexbin_raster(swz_elev, n=300, function(x) mean(x, na.rm = TRUE))
col_pal <- colorNumeric(map_palette("bruiser", n=10), hexbins$stat)
plot(hexbins, col = col_pal(hexbins$stat))
This example uses the supplied Demographic and Health Survey data on BCG vaccination in the DRC
library(leaflet)
# Load data
data("BCG_vaccination_DRC")
# Generate hexbins
hexbins <- hexbin_points(BCG_vaccination_DRC, n = 400, fun = mean, z = "coverage")
# Generate color palette
col_pal <- colorNumeric(rev(map_palette("tealberry_pie", n=10)), hexbins$stat)
# Plot
leaflet() %>% addProviderTiles("CartoDB.DarkMatter") %>%
addPolygons(data = hexbins, col = col_pal(hexbins$coverage),
fillOpacity = 0.7) %>%
addLegend(pal = col_pal, values = hexbins$coverage,
title = "Coverage")
get_colors_from_image("https://raw.githubusercontent.com/HughSt/mappalettes/master/images/nathan-lindahl-1j18807_ul0-unsplash.jpg",5)
[1] "#0C080B" "#142D40" "#425662" "#B3330C" "#F8A14B"