knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(wmts) outdir <- tempfile() dir.create(outdir) fn <- system.file("extdata","glofas.nc",package="wmts",mustWork=TRUE)
fcolour <- function(x){ brk <- c(-Inf,0.000000e+00,2.656250e-01,2.453125e+00,2.239063e+05,Inf) crp <- colorRampPalette(c("lightblue", "blue"),alpha=TRUE) col <- c("#00000000",crp(length(brk)-2),NA) col[ cut(as.numeric(x),brk) ] } tmp <- scaleImage(fcolour, c(-Inf,0.000000e+00,2.656250e-01,2.453125e+00,2.239063e+05,Inf),1) tmp <- singleTile(terra::rast(fn),fcolour,0,0,0) ## plotPalette(pal,file.path(outdir,"legend.svg"))
unlink(outdir)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.