cast_rast: automatic recasting between Raster object and raster files on...

Description Usage Arguments Details Value Author(s) Examples

View source: R/cast_rast.R

Description

function to automatically re-cast between Raster object and raster files on disk

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
cast_rast(object, to)

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

## S3 method for class 'Raster'
cast_rast(object, to)

## S3 method for class 'character'
cast_rast(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 "rastobject" (re-cast to Raster) or "rastfile" (recast to raster file).In the second case, recasting is achieved by identifying the raster file associated with the Raster object and returning its path. If no file is associated (i.e., the object is in-memory), the Raster object is written to disk on a temporary file, which path is returned

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 raster file and reads it to a Raster object through rasterr::stack()

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.