This will extract using terra::crds
, sf::st_coordinates
and
raster::coordinates
. Other packages can create methods, as this is
generic.
# S4 method for ANY
coordinates(obj, ...)
An object from which to extract the coordinates (e.g., sf
, sp
)
Ignored.
A 2 column matrix of coordinates (x and y)
library(terra)
#> terra 1.7.39
caribou <- terra::vect(x = cbind(x = stats::runif(1e1, -50, 50),
y = stats::runif(1e1, -50, 50)))
coordinates(caribou)
#> x y
#> [1,] 29.316022 -23.712320
#> [2,] 17.296624 -4.154461
#> [3,] -46.826731 28.140293
#> [4,] 29.643357 38.051599
#> [5,] 45.270619 -46.084970
#> [6,] 14.245260 -18.259664
#> [7,] -3.052855 11.851603
#> [8,] -4.401265 -35.822482
#> [9,] 3.117387 32.989251
#> [10,] -2.727219 -15.184810