Skip to contents

A class agnostic function to return or create the source of a spatial object.

Usage

get_source(x, force = FALSE)

# S3 method for SpatRaster
get_source(x, force = FALSE)

# S3 method for stars
get_source(x, force = FALSE)

# S3 method for stars_proxy
get_source(x, force = FALSE)

# S3 method for character
get_source(x, force = FALSE)

# S3 method for sf
get_source(x, force = FALSE)

# S3 method for sfc
get_source(x, force = FALSE)

# S3 method for SpatVector
get_source(x, force = FALSE)

Arguments

x

a raster source - either character i.e a local source or remote. If remote, src must be prefixed with relevant gdal module. e.g. "/vsicurl/"

force

Logical to determine if the SpatRaster or stars_proxy object should be re-saved even if on disk sources exist.

Value

character source.

Details

If a SpatRaster is provided the source of the raster is used.

See also

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

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/RtmpK5GyNX/file19823be27500.tif"
f2 <- system.file("ex/lux.shp", package="terra") 
get_source(f2)
#> [1] "/home/runner/work/_temp/Library/terra/ex/lux.shp"