Welcome to ClientVPS Mirrors

Get Started

Get Started

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

Basic usage

Here we use the shape of Austria as an example:

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

# Plot
library(tidyterra)
library(ggplot2)

# Shape 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 geolocated with the coordinates of Austria

Options

The function provides several options for expansion, alignment, and cropping.

Expand

With this option, the raster extent is expanded beyond the spatial object:

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

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

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 of alignment of image

Crop and mask

Crop and mask the image:

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 objects for geotagging

Supported image formats

rasterpic can parse the following image formats:

Need a high-speed mirror for your open-source project?
Contact our mirror admin team at info@clientvps.com.

This archive is provided as a free public service to the community.
Proudly supported by infrastructure from VPSPulse , RxServers , BuyNumber , UnitVPS , OffshoreName and secure payment technology by ArionPay.