accessory function to check if an object passed to the function corresponds to a *Spatial Object, a sf object, a R raster object, a file corresponding to a vector, or a file corresponding to a raster. NOTE: to check only for vector or raster types, the associated functions get_vectype and get_rastype can be used, with the same syntax.

get_spatype(in_object, abort = TRUE)

Arguments

in_object

either a R object or a character string pointing to a vector or raster layer

abort

logical if TRUE the function aborts if object is not recognized as an R spatial file or valid vector or raster file; if FALSE, a warning is shown and `NA`` is returned.

Value

character ("spobject" | "sfobject" | "rastobject | " vectfile" | rastfile " | sprawlext), or NA if the input does not belong to any spatial category and abort == FALSE

Examples

library(sprawl.data) # input is a raster file in_rast <- system.file("extdata/MODIS_test", "EVIts_test.tif", package = "sprawl.data") get_spatype(in_rast)
#> [1] "rastfile"
# input is a raster object obj <- read_rast(in_rast) get_spatype(in_rast)
#> [1] "rastfile"
# input is a shapefile in_vect <- system.file("extdata/shapes","lc_polys.shp", package = "sprawl.data") get_spatype(in_vect)
#> [1] "vectfile"
# input is a `sp` object obj <- read_vect(in_vect, as_sp = TRUE) get_spatype(obj)
#> [1] "spobject"
# input is a `sf` object obj <- read_vect(in_vect) get_spatype(obj)
#> [1] "sfobject"
# input is a `sprawlext` object obj <- get_extent(in_vect) get_spatype(obj)
#> [1] "sprawlext"