Skip to contents

Assign a time period to a SpatRaster object

Usage

assign_time_period(raster_layer, year_)

Arguments

raster_layer

A SpatRaster object

year_

A string representing a year

Value

The original SpatRaster object, with an assigned time period

Examples

# Load terra package
library(terra)
#> terra 1.7.71
# Create example SpatRaster
r <- rast(nrow=10, ncol=10)
r[] <- 1:ncell(r)
# Assign a time period
assign_time_period(r, "2023")
#> class       : SpatRaster 
#> dimensions  : 10, 10, 1  (nrow, ncol, nlyr)
#> resolution  : 36, 18  (x, y)
#> extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (CRS84) (OGC:CRS84) 
#> source(s)   : memory
#> name        : lyr.1 
#> min value   :     1 
#> max value   :   100 
#> time (years): 2023