Skip to contents

A class agnostic function to return the dimensions of a spatial object. Only applicable for rasters - spatial vectors will return NULL.

Usage

get_dim(x, ...)

# S3 method for SpatRaster
get_dim(x, ...)

# S3 method for SpatVector
get_dim(x, ...)

# S3 method for sf
get_dim(x, ...)

# S3 method for sfc
get_dim(x, ...)

# S3 method for stars
get_dim(x, ...)

# S3 method for stars_proxy
get_dim(x, ...)

# S3 method for character
get_dim(x, ...)

# S3 method for ezgrid
get_dim(x, ...)

Arguments

x

A spatial object, file path or source

...

Not used

See also

Other spatial helpers (class agnostic): get_ext(), get_proj(), get_source()

Examples

f <- system.file("ex/elev.tif", package = "terra")
get_dim(f)
#> NULL
get_dim(terra::rast(f))
#> [1] 95 90
f2 <- system.file("ex/lux.shp", package = "terra")
get_dim(f2)
#> NULL