A class agnostic function to return or create the source of a spatial object.
Usage
get_source(x, force = FALSE)
# S3 method for class 'SpatRaster'
get_source(x, force = FALSE)
# S3 method for class 'stars'
get_source(x, force = FALSE)
# S3 method for class 'stars_proxy'
get_source(x, force = FALSE)
# S3 method for class 'character'
get_source(x, force = FALSE)
# S3 method for class 'sf'
get_source(x, force = FALSE)
# S3 method for class 'sfc'
get_source(x, force = FALSE)
# S3 method for class 'SpatVector'
get_source(x, force = FALSE)Examples
f <- system.file("ex/elev.tif", package = "terra")
get_source(f)
#> [1] "/home/runner/work/_temp/Library/terra/ex/elev.tif"
get_source(terra::rast(f), force = TRUE)
#> [1] "/tmp/RtmpsFwRQg/file230ced37923.tif"
f2 <- system.file("ex/lux.shp", package = "terra")
get_source(f2)
#> [1] "/home/runner/work/_temp/Library/terra/ex/lux.shp"