Check if a R
object or a filename correspond to a valid vector
object, to a vector file or none of the above. Useful to detect which kind
of input is passed to a function and abort / do something in the case of
"wrong" input.
get_vectype(in_vect, abort = TRUE)
in_vect | name of an |
---|---|
abort | If TRUE, and |
character
equal to "vectfile" (if in_vect
is a raster file),
spobject
(if in_vect
is of class spatial
), sfobject
(if in_vect
is of class sf
), or NA
if it is neither (unless abort
== TRUE)
# input is a shapefile in_vect <- system.file("extdata/shapes","lc_polys.shp", package = "sprawl.data") get_vectype(in_vect)#> [1] "vectfile"#> [1] "spobject"#> [1] "sfobject"#> [1] "sprawlext"