The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Get started

Getting started with rasterpic is easy: you need an image file (png, jpeg/jpg or tiff/tif) and a spatial object from the sf, terra or stars packages.

Basic usage

This example uses the shape of Austria:

library(sf)
library(terra)
library(rasterpic)

# Load plotting packages.
library(tidyterra)
library(ggplot2)

# Set the spatial object and image.
x <- read_sf(system.file("gpkg/austria.gpkg", package = "rasterpic"))
img <- system.file("img/vertical.png", package = "rasterpic")

# Create the raster.
default <- rasterpic_img(x, img)

autoplot(default) +
  geom_sf(data = x)
FigureĀ 1: Raster map geotagged with the coordinates of Austria

Options

rasterpic_img() provides several options for expansion, alignment, cropping and masking.

Expand

This option expands the raster extent beyond the spatial object:

expand <- rasterpic_img(x, img, expand = 1)

autoplot(expand) +
  geom_sf(data = x)
FigureĀ 2: Example image expansion

Alignment

Choose the alignment of the image within the spatial extent:

bottom <- rasterpic_img(x, img, valign = 0)

autoplot(bottom) +
  geom_sf(data = x)
FigureĀ 3: Example image alignment

Crop and mask

Crop the raster and mask it to the object shape:

mask <- rasterpic_img(x, img, crop = TRUE, mask = TRUE)

autoplot(mask)

maskinverse <- rasterpic_img(x, img, crop = TRUE, mask = TRUE, inverse = TRUE)

autoplot(maskinverse)
FigureĀ 4: Example of masked image
FigureĀ 5: Example of inverse masked image

Supported spatial input classes

rasterpic_img() supports the following input classes:

rasterpic_img() is an S3 generic. The methods for extent-like inputs use the object extent, and vector methods can also mask the image to the object shape.

Supported image formats

rasterpic can parse the following image formats:

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.