tonerToTrans {mapmisc}R Documentation

Convert RGB maps to semi-transparent

Description

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

Usage

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

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

Details

The difference between these functions is that tonerToTrans converts white to transparent, whereas rgbtToIndex uses the transparency layer. The former is intended for 'stamen-toner' maps.

Value

A RasterLayer with indexed colours

Author(s)

Patrick Brown

See Also

openmap

Examples


## Not run: 

	rgbMap = openmap(c(0,10), zoom=3, path='stamen-toner')
	names(rgbMap)
	plotRGB(rgbMap)
	
	transMap = tonerToTrans(rgbMap, col='blue')
	names(transMap)
	par(bg='red')
	plot(transMap)

	rgbMap[['stamen.tonerTrans']] = 255-rgbMap[['stamen.tonerRed']]
	rgbtMap = rgbtToIndex(rgbMap)
	plot(rgbtMap)

## End(Not run)

[Package mapmisc version 1.8.1 Index]