Learn R Programming

tidyterra (version 1.3.0)

glimpse.Spat: Preview Spat* objects

Description

glimpse() is like a transposed version of print(): layers/columns run down the page and data runs across. This makes it possible to see every layer/column in a Spat* object.

Usage

# S3 method for SpatRaster
glimpse(x, width = NULL, ..., n = 10, max_extra_cols = 20)

# S3 method for SpatVector glimpse(x, width = NULL, ..., n = 10, max_extra_cols = 20)

Value

Original x is invisibly returned, allowing glimpse() to be used within a data pipeline.

Arguments

x

A SpatRaster created with terra::rast() or a SpatVector created with terra::vect().

width

Width of output: defaults to the setting of the width option (if finite) or the width of the console.

...

Arguments passed to as_tibble.SpatRaster() or as_tibble.SpatVector() methods.

n

Maximum number of rows to show.

max_extra_cols

Number of extra columns or layers to print abbreviated information for, if n is too small for the Spat* object.

<a href="https://CRAN.R-project.org/package=terra"><span class="pkg">terra</span></a> equivalent

print().

Methods

Implementation of the generic dplyr::glimpse() methods for Spat* objects.

See Also

tibble::print.tbl_df()

Other dplyr verbs that operate on columns: mutate.Spat, pull.Spat, relocate.Spat, rename.Spat, select.Spat

Examples

Run this code

library(terra)

# SpatVector
v <- vect(system.file("extdata/cyl.gpkg", package = "tidyterra"))

v |> glimpse(n = 2)

# Use in a pipeline.
v |>
  glimpse() |>
  mutate(a = 30) |>
  # With options.
  glimpse(geom = "WKT")

# SpatRaster
r <- rast(system.file("extdata/cyl_elev.tif", package = "tidyterra"))

r |> glimpse()

# Use in a pipeline.
r |>
  glimpse() |>
  mutate(b = elevation_m / 100) |>
  # With options
  glimpse(xy = TRUE)

Run the code above in your browser using DataLab