getPngLayer | R Documentation |
.png
LayerGet a RasterBrick
from a .png
image cut using the shape of a spatial object. The .png
file could be either a local file or extracted from a given url.
getPngLayer(
x,
pngpath,
align = "center",
margin = 0,
crop = FALSE,
mask = TRUE,
inverse = FALSE,
dwmode = "curl",
...
)
x |
an |
pngpath |
local path or url of a |
align |
set how the |
margin |
inner margin, zooms out the |
crop |
|
mask |
|
inverse |
logical. If |
dwmode |
Set the download mode. It could be |
... |
additional arguments for downloading the file. See |
The effect of align
would differ depending of the aspect ratio of x
and pngpath
. To obtain a fitted tile from pngpath
given that x
is the tile to fit, set margin = 0 , crop = TRUE
.
A RasterBrick
object is returned.
The accuracy of the final plot would depend on the quality of the .png
file,
the scale of x
and the resolution setup of the graphic device. Exporting to svg
is highly
recommended.
dieghernan, https://github.com/dieghernan/
pngLayer
library(sf)
mtq <- st_read(system.file("gpkg/mtq.gpkg", package = "cartography"))
#Local file
dirpng <- system.file("img/LogoMartinique.png", package = "cartography")
mask <- getPngLayer(mtq, dirpng)
## Not run:
#Remote file
urlpng <- "https://i.imgur.com/gePiDvB.png"
masksea <- getPngLayer(mtq, urlpng, mode = "wb", inverse = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.