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)
library(terra)
library(rasterpic)
# Plot
library(tidyterra)
library(ggplot2)
# Shape and image
<- read_sf(system.file("gpkg/austria.gpkg", package = "rasterpic"))
x <- system.file("img/vertical.png", package = "rasterpic")
img
# Create!
<- rasterpic_img(x, img)
default
autoplot(default) +
geom_sf(data = x)
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
autoplot(expand) +
geom_sf(data = x)
Decide where to align the image:
<- rasterpic_img(x, img, valign = 0)
bottom
autoplot(bottom) +
geom_sf(data = x)
Create impressive maps!:
<- rasterpic_img(x, img, crop = TRUE, mask = TRUE)
mask
autoplot(mask)
<- rasterpic_img(x, img, crop = TRUE, mask = TRUE, inverse = TRUE)
maskinverse
autoplot(maskinverse)
Spatial object of the sf package:
sf
, sfc
, sfg
or
bbox
.
Spatial objects of the terra package:
SpatRaster
, SpatVector
,
SpatExtent
.
A vector of coordinates with the form
c(xmin, ymin, xmax, yman)
rasterpic can parse the following image formats:
png
files.jpg/jpeg
files.tif/tiff
files.