This is an accessory function to generate binary or 4 color palettes to be used in the leaflet maps.

gen_pal(mode, pal, type = "leaflet")

Arguments

mode

Mode to generate the palette. "bin" is suitable for binary maps (thresholded maps). "quad" will return a 4 color palette, suitable for maps showing differences from a (binary) reference to a distinct scenario (either future or past).

pal

Which palete to use. Character string indicating the name of the palette. Can also be a character vector of colors, in which case two or four should be supplied. The following pre-seted (and tested) palettes are available and are recommended: These are the available palettes for binary maps:

  • "BlGr": Blue and dark gray

  • "GeGr": Green and dark gray

  • "OrGr": Orange and dark gray

  • "YeBl": Yellow and dark blue

These are the available color schemes for 4 colors maps:

  • "Cont": Dark gray, Yellow, Purple, Light green/blue

  • "Bang": Black, Gold, Light green, Blue Based on Bang Wong's palette.

  • "Happy": Dark gray, Violet, Orange, Red tone

All of these palettes are colorblind safe.

For the continuous colors, you can use any of the palettes available for the colorNumeric function (see colorNumeric) (THIS FUNCTION WILL NOT WORK WITH CONTINUOUS COLORS. SUPPLY THE NAME DIRECTLY IN THE SDMVIS FUNCTIONS.).

type

Which type of palette to return. If "leaflet" (default), a leaflet ready palette is returned. Any other value will return a character vector of colors.

Value

A palette to produce interactive SDM/ENM maps.

Examples

#> Loading required package: sp
#> rgdal: version: 1.5-23, (SVN revision 1121) #> Geospatial Data Abstraction Library extensions to R successfully loaded #> Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29 #> Path to GDAL shared files: /Users/runner/work/_temp/Library/rgdal/gdal #> GDAL binary built with GEOS: TRUE #> Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721] #> Path to PROJ shared files: /Users/runner/work/_temp/Library/rgdal/proj #> PROJ CDN enabled: FALSE #> Linking to sp version:1.4-5 #> To mute warnings of possible GDAL/OSR exportToProj4() degradation, #> use options("rgdal_show_exportToProj4_warnings"="none") before loading rgdal. #> Overwritten PROJ_LIB was /Users/runner/work/_temp/Library/rgdal/proj
data(thresholded_sdm) binpal <- gen_pal(mode = "bin", pal = "BlGr") leaflet()%>% addProviderTiles("Esri.OceanBasemap") %>% addRasterImage(thresholded_sdm[[1]], colors = binpal, opacity = 0.9)
#> Warning: Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
#> Warning: Discarded datum World Geodetic System 1984 in Proj4 definition
#> Warning: Discarded ellps WGS 84 in Proj4 definition: +proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs
#> Warning: Discarded datum World Geodetic System 1984 in Proj4 definition
#> Warning: Some values were outside the color scale and will be treated as NA