cast_vect: cast a vector object to a different 'R' spatial class or to a...

Description Usage Arguments Details Value Author(s) Examples

Description

function to automatically re-cast a "vector" object to a given "class" specified by the to argument.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
cast_vect(object, to)

## Default S3 method:
cast_vect(object, to)

## S3 method for class 'sf'
cast_vect(object, to)

## S3 method for class 'sfc'
cast_vect(object, to)

## S3 method for class 'Spatial'
cast_vect(object, to)

## S3 method for class 'character'
cast_vect(object, to)

Arguments

object

either an R object of class sf, sfc or Spatial, or a character string corresponding to a filename (with full path)

to

character indicating to which type of object the input should be re-casted. It can be "sfobject" (re-cast to sf), "spobject" (recast to Spatial) or "vectfile" (re-cast to a shapefile)

Details

If object is a valid R spatial object, it is automatically converted to an object of a different class if needed (e.g., from sf to Spatial and viceversa, or from sf to a vector file through sprawl::write_shape). If it is a character string, the function checks if it corresponds to a valid vector file and reads it to a sf or Spatial object through sprawl::read_vect

Value

returns the same object, casted to the "class" specified by to (or the exact same object in case object is already of "class" to)

Author(s)

Lorenzo Busetto, phD (2017) lbusett@gmail.com

Examples

1
2
3
4
## Not run: 
 #EXAMPLE1
 
## End(Not run)

IREA-CNR-MI/sprawl documentation built on May 27, 2019, 1:12 p.m.