tidyterra extends the tidyverse to work with SpatRaster and SpatVector objects created by the terra package. It provides tidyverse-style methods and ggplot2 geoms/scales for plotting spatial data.
Behavior varies by object type:
- SpatVector: Methods use
terra::as.data.frame() coercion. Rows represent geometries and columns represent attributes. - SpatRaster: Methods treat layers as columns and cells as rows. For example, using
select(spatraster, 1) will select the first layer of the object.
Most implemented methods return the same object type as the input, unless the function is specifically designed to return a different type (e.g., as_tibble() returns a tibble).