Get the extent (bounding box) of a spatial object.

getExtent(x, ...)

# S4 method for ANY
getExtent(x)

# S4 method for geom
getExtent(x)

# S4 method for Spatial
getExtent(x)

# S4 method for sf
getExtent(x)

# S4 method for Raster
getExtent(x)

# S4 method for SpatRaster
getExtent(x)

# S4 method for matrix
getExtent(x)

Arguments

x

the object from which to derive the extent.

...

other arguments.

Value

A tibble of the lower left and upper right corner coordinates of the extent of x. This table two columns (x and y) and two rows (minimum and maximum).

See also

Examples


getExtent(gtGeoms$line)
#> # A tibble: 2 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1 -34.6   -40
#> 2  34.6    40

gc_sp(gtGeoms$line) %>%
  getExtent()
#> # A tibble: 2 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1 -34.6   -40
#> 2  34.6    40

gc_sf(gtGeoms$line) %>%
  getExtent()
#> # A tibble: 2 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1 -34.6   -40
#> 2  34.6    40

gc_raster(gtGeoms$grid$categorical) %>%
  getExtent()
#> # A tibble: 2 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1     0     0
#> 2    60    56

gc_terra(gtGeoms$grid$categorical) %>%
  getExtent()
#> # A tibble: 2 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1     0     0
#> 2    60    56

getExtent(x = matrix(0, 3, 5))
#> # A tibble: 2 × 2
#>       x     y
#>   <dbl> <dbl>
#> 1     0     0
#> 2     5     3