tilesLayer: Plot a Raster Object

View source: R/tilesLayer.R

tilesLayerR Documentation

Plot a Raster Object

Description

Plot a raster object over a map. It can be used to plot images from getPngLayer.

Usage

tilesLayer(x, add = FALSE, ...)

pngLayer(x, add = FALSE, ...)

Arguments

x

a RasterBrick object; getPngLayer function output these objects.

add

whether to add the layer to an existing plot (TRUE) or not (FALSE).

...

bgalpha, interpolate, or other arguments passed to be passed to plotRGB

Note

This function is a wrapper for plotRGB from the raster package. The accuracy of the final plot depends on the quality of the *.png file, the scale of x and the resolution setup of the graphic device.

Author(s)

dieghernan, https://github.com/dieghernan/

See Also

getPngLayer

Examples

library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package = "cartography"))

# Local image
dirpng <- system.file("img/LogoMartinique.png", package = "cartography")
mask <- getPngLayer(mtq, dirpng, crop = TRUE, margin = 0.5)
par(mar = c(0,0,0,0))
ghostLayer(mtq)
pngLayer(mask, add = TRUE)

## Not run: 
# Remote image
urlpng = "https://i.imgur.com/gePiDvB.png"
masksea <- getPngLayer(mtq, urlpng, mode = "wb", inverse = TRUE, margin = 0.5)
#Combine
par(mar = c(0,0,0,0))
ghostLayer(mtq)
pngLayer(mask, add = TRUE)
pngLayer(masksea, add = TRUE)
plot(st_geometry(mtq), border="orange", add=TRUE)

## End(Not run)

cartography documentation built on Sept. 14, 2023, 5:08 p.m.