get_spatype: check the "spatial type" of an object or file

Description Usage Arguments Value Examples

View source: R/get_spatype.R

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
get_spatype(object, abort = FALSE)

## Default S3 method:
get_spatype(object, abort = FALSE)

## S3 method for class 'character'
get_spatype(object, abort = FALSE)

## S3 method for class 'Raster'
get_spatype(object, abort = FALSE)

## S3 method for class 'sf'
get_spatype(object, abort = FALSE)

## S3 method for class 'sfc'
get_spatype(object, abort = FALSE)

## S3 method for class 'Spatial'
get_spatype(object, abort = FALSE)

Arguments

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

Value

character vector equal to spobject, sfobject, rastobject, vectfile or rastfile

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
library(sprawl.data)
# input is a raster file
get_spatype(system.file("extdata","sprawl_EVItest.tif", package = "sprawl.data"))

# input is a shapefile
shp_file <- system.file("extdata","lc_polys.shp", package = "sprawl.data")
get_spatype(shp_file)

# input is a `sp` object
obj <- read_vect(shp_file, as_sp = TRUE)
get_spatype(obj)

# input is a `sf` object
obj <- read_vect(shp_file)
get_spatype(obj)

## End(Not run)

IREA-CNR-MI/sprawl documentation built on Aug. 6, 2017, 12:56 p.m.