Skip to contents

Assumes that the name of the raster layer is the name of the variable if static is true, otherwise, the user must supply the correct variable name. If static is false, the name of the raster layer is assumed to be the time variable.

Usage

rast_to_df(rast, static = TRUE, varname = NULL)

Arguments

rast

SpatRaster

static

True if no temporal dimension, False else.

varname

The variable name, only required if static is False.

Value

data.frame

Examples

ne <- gen_naturalearth_cover()
#> Reading layer `ne_10m_land' from data source 
#>   `/Volumes/T7/priogrid_data/Natural Earth Physical 10m Land/5.1.1/92da9800-4520-4e87-a855-b28255452189/ne_10m_land/ne_10m_land.shp' 
#>   using driver `ESRI Shapefile'
#> Simple feature collection with 11 features and 3 fields
#> Geometry type: MULTIPOLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
#> Geodetic CRS:  WGS 84
#> Warning: Polygons transformed to raster CRS. To avoid on-the-fly coordinate transformation, ensure that st_crs() returns the same result for both raster and polygon inputs.
rast_to_df(ne)
#> Key: <pgid>
#>        pgid naturalearth_cover
#>       <num>             <lgcl>
#>    1:    31               TRUE
#>    2:    32               TRUE
#>    3:    33               TRUE
#>    4:    34               TRUE
#>    5:    35               TRUE
#>   ---                         
#> 2166:  2977               TRUE
#> 2167:  2978               TRUE
#> 2168:  2979               TRUE
#> 2169:  2980               TRUE
#> 2170:  2981               TRUE