View source: R/ts_makeframes.R

ts_makeframes | R Documentation |

Create spatial ggplots of a raster time series

ts_makeframes( x_list, r_type = NULL, minq = 0.02, maxq = 0.98, samplesize = 1000, blacken_NA = FALSE, l_indices = NULL, alpha = NULL, hillshade = NULL, ... )

`x_list` |
a list of raster objects. |

`r_type` |
(Optional) character, one of |

`minq` |
(Optional) numeric, lower quantile boundary for the stretch. Default is |

`maxq` |
(Optional) numeric, upper quantile boundary for the stretch. Default is |

`samplesize` |
(Optional) numeric, number of samples per layer to determine the quantile from. See sampleRegular for details on the sampling. Default is |

`blacken_NA` |
(Optional) logical. If |

`l_indices` |
(Optional) numeric, a vector of layer indices specifying which layers are to be plotted. Should contain 3 values for an RGB image or a single value for a discrete or gradient image. By default, chooses the first three layers if |

`alpha` |
(Optional) numeric. The opacity of the plot. Default is 1. |

`hillshade` |
(Optional) A raster layer. If one is provided, it will be used as the base layer and plotted with ggR while the raster layers from x_list will be plotted over it with a default |

`...` |
(Optional) further arguments for the plotting. |

A linear percent stretch will be applied to each band to improve contrast. #

*(X - Low_{in}) * \frac{((High_{out}-Low_{out})}{(High_{in}-Low_{in}))} + Low_{out}*

# The stretch parameters
# *High_{out}*,*Low_{out}*,*High_{in}*,*Low_{in}*
# are calculated separately for each band based on the `minq`

and `maxq`

which are first applied to `samplesize`

regular samples (see sampleRegular) of each individual layer.
From these, across all layers belonging to a certain band, the minimum and maximum values are taken as the stretching parameters for the linear stretch, which is performed using rescaleImage. Discrete `r_type`

s will not be stretched.
To further enhance the plots, consider using functionalities implemented in moveVis,
(see http://movevis.org/ ). For example, a northarrow may be added to all frames using add_northarrow.

A list of ggplots

Johannes Mast

#Setup # Load example dataset at a greatly increased interval x_list <- MODIS_SI_ds[seq(1,length(MODIS_SI_ds),25)] x_dates <- do.call(c, lapply(MODIS_SI_ds,attr,"time") )[seq(1,length(MODIS_SI_ds),25)] #Fill NAs x_list_filled <- ts_fill_na(x_list) #Make a sequence of output dates, double the length of input dates out_dates <-seq.POSIXt(from = x_dates[1], to = x_dates[length(x_dates)],length.out = length(x_dates)*2 ) #For each output date, interpolate a raster image from the input files r_list_out <- ts_raster(r_list = x_list_filled, r_times = x_dates, out_times = out_dates, fade_raster = TRUE) #Create the frames # as from the desired layers r_frames <- ts_makeframes(x_list = r_list_out,samplesize = 10, l_indices = c(1,4,3))

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.