tonerToTrans function

Convert RGB maps to semi-transparent

Convert RGB maps to semi-transparent

Stamen-toner maps are 3-layer RGB rasters, which are converted to single-layer rasters with indexed colours with whites becoming transparent.

tonerToTrans(x, pattern="(red|green|blue)$", power = 0.5, col='black', threshold=Inf, mostCommon=1)

Arguments

  • x: A RasterStack with RGB colours, such as from openmap with path='stamen-toner'
  • pattern: string passed to grep to find RGB layers.
  • power: Values below 1 increase opacity, above 1 increases transparency
  • col: colour for resulting map
  • threshold: colours above this value are transparent
  • mostCommon: integer vector, the most common colours are converted to transparent

Returns

A SpatRast with indexed colours

Author(s)

Patrick Brown

See Also

openmap

Examples

origMap = openmap( c(-11, 9), path='cartodb-nolabels', buffer=2, verbose=TRUE ) oldpar= map.new(origMap, bg='green') plot(origMap, add=TRUE) transMap = tonerToTrans(origMap, mostCommon=1) names(transMap) map.new(transMap, bg='green') plot(transMap, add=TRUE) par(oldpar)
  • Maintainer: Patrick Brown
  • License: GPL
  • Last published: 2024-04-16

Useful links