Skip to contents

A class agnostic function to return the bounding extent (i.e. bounding box) of a spatial object.

Usage

get_ext(x, ...)

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

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

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

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

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

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

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

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

Arguments

x

A spatial object, file path or source

...

Not used

Value

A numeric vector of length 4. Values are returned as: "xmin", "xmax", "ymin", "ymax"

See also

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

Examples

f <- system.file("ex/elev.tif", package="terra") 
get_ext(f)
#> [1]  5.741667  6.533333 49.441667 50.191667
get_ext(terra::rast(f))
#> [1]  5.741667  6.533333 49.441667 50.191667
f2 <- system.file("ex/lux.shp", package="terra") 
get_ext(f2)
#> [1]  5.744140  6.528252 49.447807 50.181622