Starting with rasterpic is very easy! You just need a image (png
, jpeg/jpg
or tif/tiff
) and a spatial object (from the sf or the terra) package to start using it
We use here as an example the shape of Austria:
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1; sf_use_s2() is TRUE
library(terra)
#> terra 1.5.12
library(rasterpic)
<- st_read(system.file("gpkg/austria.gpkg",
x package = "rasterpic"
),quiet = TRUE
)<- system.file("img/vertical.png",
img package = "rasterpic"
)
# Create!
<- rasterpic_img(x, img)
default
plotRGB(default)
plot(st_geometry(x), add = TRUE, col = "grey90")
The function provides several options for expanding, alignment and cropping.
With this option the image is zoomed out of the spatial object:
<- rasterpic_img(x, img, expand = 1)
expand
plotRGB(expand)
plot(st_geometry(x), add = TRUE, col = "grey90")
Decide where to align the image:
<- rasterpic_img(x, img, valign = 0)
bottom
plotRGB(bottom)
plot(st_geometry(x), add = TRUE, col = "grey90")
Create impressive maps!:
<- rasterpic_img(x, img, crop = TRUE, mask = TRUE)
mask
plotRGB(mask)
<- rasterpic_img(x, img,
maskinverse crop = TRUE,
mask = TRUE,
inverse = TRUE
)
plotRGB(maskinverse)