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 class 'SpatRaster'
get_dim(x, ...)
# S3 method for class 'SpatVector'
get_dim(x, ...)
# S3 method for class 'sf'
get_dim(x, ...)
# S3 method for class 'sfc'
get_dim(x, ...)
# S3 method for class 'stars'
get_dim(x, ...)
# S3 method for class 'stars_proxy'
get_dim(x, ...)
# S3 method for class 'character'
get_dim(x, ...)
# S3 method for class 'ezgrid'
get_dim(x, ...)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