glimpse.Spat {tidyterra}R Documentation

Get a nice glimpse of your ⁠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 class 'SpatRaster'
glimpse(x, width = NULL, ..., n = 10, max_extra_cols = 20)

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

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. See dplyr::glimpse().

...

Arguments passed on to as_tibble() methods for SpatRaster and SpatVector. See as_tibble.SpatRaster().

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.

Value

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

terra equivalent

print()

Methods

Implementation of the generic dplyr::glimpse() function 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

Other dplyr methods: arrange.SpatVector(), bind_cols.SpatVector, bind_rows.SpatVector, count.SpatVector(), distinct.SpatVector(), filter-joins.SpatVector, filter.Spat, group-by.SpatVector, mutate-joins.SpatVector, mutate.Spat, pull.Spat, relocate.Spat, rename.Spat, rowwise.SpatVector(), select.Spat, slice.Spat, summarise.SpatVector()

Examples


library(terra)

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

v %>% glimpse(n = 2)

# Use on 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 on a pipeline
r %>%
  glimpse() %>%
  mutate(b = elevation_m / 100) %>%
  # With options
  glimpse(xy = TRUE)

[Package tidyterra version 0.6.1 Index]