knitr::opts_chunk$set(echo = TRUE)
This vignette describes a basic application of the VARMER
library, which provides methods to combine satellite-based or model-based gridded images with ground-based observed time-series [1].
Install the latest stable version (from CRAN):
install.packages("VARMER")
VARMER
:library(zoo) library(sf) library(raster) library(tictoc) library(cluster) library(parallel) #library(ggplot2) library(VARMER)
First, daily time series of maximum temperature observations in 34 stations located in Ecuador will be used for this example, from 2004-01-01 to 2004-01-10, which are available in the ecuador.tmax.zoo dataset provided in the VARMER
package (for your own application, this dataset might be read from a CSV file or a zoo
file). In addition, the ecuador.tmax.stations.df dataset contains information about the IDs and spatial coordinates of each station (for your own application, this dataset might be read from a CSV file).
data(ecuador.tmax.zoo) data(ecuador.tmax.stations.df)
Secondly, we need to load the WRF output. For this example, the model-data was obtained from a WRF v3.6.1 simulation at 10Km spatial resolution and at daily temporal resolution.
data(ecuador.tmax.wrf.out)
First, we would like to visualize the first six rows of the spatial metadata:
head(ecuador.tmax.stations.df)
Plotting the daily precipitation time series for the first station (code: M0001).
main <- paste("Daily maximum temperature for the station", ecuador.tmax.stations.df$CODIGO[1]) ylab <- "Maximum temperature [°C]" x.ts <- ecuador.tmax.zoo[,1] plot(x.ts, main=main, ylab= ylab, col="blue") grid()
Plotting the average maximum temperature from WRF output, and overlying the boundaries of the study area (only its first attribute):
wrfout.total <- mean(ecuador.tmax.wrf.out, na.rm=FALSE) plot(wrfout.total, main = "WRF output [Jan-2004] ", xlab = "Longitude", ylab = "Latitude")
VARMER
Finally, you need to define the output directory (drty.out
) before running VARMER
. Then, you can run the varmer.ts
function as follows:
varmer.ts(x=ecuador.tmax.zoo, x.metadata=ecuador.tmax.stations.df, v=ecuador.tmax.wrf.out, lat='LAT', lon='LON', drty.out="~/Documentos/dataset_ecuador")
\newpage
If VARMER
runs without problems, the final merged product (individual GeoTiff files) will be stored in your user-defined drty.out
directory.
This tutorial was built under:
sessionInfo()$platform sessionInfo()$R.version$version.string paste("VARMER", sessionInfo()$otherPkgs$VARMER$Version)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.