Description Usage Arguments Value Author(s) See Also Examples
View source: R/stack_season_dates.R
Estimate and stack the beginning and end of growing seasons.
1 | stack_season_dates(x, ts_freq = 23)
|
x |
A Raster* object (see |
ts_freq |
The frequence of time series to be passed to phases (see ?phases). |
A rasterStack object (see Raster-class
) of biginning
and end of the season for each pixel.
Issoufou Liman
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | library(raster)
## making some data
nam<- seq.Date(from = as.Date('2016-01-01'), to = as.Date ('2018-12-31'), by = 16)
dx11 <- c(1.30, 1.15, 1.50, 2.00, 2.01, 3.00, 3.20, 4.76, 3.50, 3.00, 2.40, 2.00, 1.50)
dx12 <-c(1.29, 1.1, 1.49, 1.99, 2, 3.1, 4.5, 4, 2.8, 2.5, 2.3, 1.6, 1.59)
names(dx11) <- nam[1:length(dx11)]
names(dx12) <- nam[1:length(dx12)]
dx1 <- c(dx11, dx12)
names(dx1) <- nam[1:length(dx1)]
dx2 <- dx1
dx2[21:length(dx2)] <- NA
dy11 <- c(1.40, 1.00, 1.50, 2.00, 5.00, 3.00, 1.00, 0.76, 2.00, 1.00, 3.50, 3.00, 1.50)
dy12 <- c(1.30, 1.10, 1.40, 2.01, 5.50, 2.80, 1.01, 1, 2.03, 1.09, 3.10, 3.00, 1.50)
names(dy11) <- nam[1:length(dy11)]
names(dy12) <- nam[1:length(dy12)]
dy1 <- c(dy11, dy12)
names(dy1) <- nam[1:length(dy1)]
dy2 <- dy1
dy2[23:length(dy2)] <- NA
df <- rbind(dx1, dx2, dy1, dy2)
## creating a raster stack and assigning the data above as its pixels values
s <- raster::raster(nrows=2, ncols=2, xmn=0, xmx=10)
rlist <- vector('list', ncol(df))
for(i in 1:ncol(df)){
rlist [[i]] <- raster::setValues(s, df[,i])
}
s <- do.call('stack', rlist)
names(s) <- colnames(df)
## calling the function on the created raster stack.
x <- stack_season_dates(s, ts_freq = 12)
## check it up!
values(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.