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:
Options
rasterpic_img() provides several options for expansion, alignment, cropping and masking.
Expand
This option expands the raster extent beyond the spatial object:
Alignment
Choose the alignment of the image within the spatial extent:
Crop and mask
Crop the raster and mask it to the object shape:
rasterpic_img() supports the following input classes:
-
sf classes:
sf, sfc, sfg or bbox.
-
terra classes:
SpatRaster, SpatVector and SpatExtent.
-
stars classes:
stars.
- A numeric coordinate vector of the form
c(xmin, ymin, xmax, ymax).
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.
rasterpic can parse the following image formats:
-
png files.
-
jpeg/jpg files.
-
tiff/tif files.