Description Usage Arguments Value Author(s) References See Also Examples
Merging of satellite datasets with ground observations using Random Forests (RF)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | RFmerge(x, ...)
## Default S3 method:
RFmerge(x, metadata, cov, mask, training,
id="id", lat = "lat", lon = "lon", ED = TRUE,
seed = NULL, ntree = 2000, na.action = stats::na.omit,
parallel=c("none", "parallel", "parallelWin"),
par.nnodes=parallel::detectCores()-1,
par.pkgs= c("raster", "randomForest", "zoo"), write2disk=FALSE,
drty.out, use.pb=TRUE, verbose=TRUE,...)
## S3 method for class 'zoo'
RFmerge(x, metadata, cov, mask, training,
id="id", lat = "lat", lon = "lon", ED = TRUE,
seed = NULL, ntree = 2000, na.action = stats::na.omit,
parallel=c("none", "parallel", "parallelWin"),
par.nnodes=parallel::detectCores()-1,
par.pkgs= c("raster", "randomForest", "zoo"), write2disk=FALSE,
drty.out, use.pb=TRUE, verbose=TRUE, ...)
|
x |
data.frame witht the ground-based values that will be used as the dependent variable to train the RF model. |
metadata |
data.frame with the metadata of the ground-based stations. At least, it MUST have the following 3 columns: |
cov |
List with all the covariates used as independent variables in the Random Forest model. The individual covariates can be a RasterStack or RasterBrick object when they vary in time, or they can be a single RasterLayer object when they do not change in time (e.g., a digital elevation model). |
mask |
OPTIONAL. If provided, the final merged product maks out all values in |
training |
Numeric indicating the percentage of stations that will be used in the training set. |
id |
Character, with the name of the column in |
lat |
Character, with the name of the column in |
lon |
Character, with the name of the column in |
ED |
logical, should the Euclidean distances be computed an used as covariates in the random fores model?. The default value is |
seed |
Numeric, indicating a single value, interpreted as an integer, or null. |
parallel |
character, indicates how to parallelise ‘RFmerge’ (to be precise, only the evaluation of the objective function |
par.nnodes |
OPTIONAL. Used only when |
par.pkgs |
OPTIONAL. Used only when |
ntree |
Numeric indicating the maximum number trees to grow in the Random Forest algorithm. The default value is set to 2000. This should not be set to too small a number, to ensure that every input row gets predicted at least a few times. If this value is too low, the prediction may be biased. |
na.action |
A function to specify the action to be taken if NAs are found. (NOTE: If given, this argument must be named.) |
write2disk |
logical, indicates if the output merged raster layers and the training and avaluation datasets (two files each, one with time series and other with metadata) will be written to the disk. By default |
drty.out |
Character with the full path to the directory where the final merged product will be exported as well as the training and evaluation datasets. Only used when |
use.pb |
logical, indicates if a progress bar should be used to show the progress of the random forest computations (it might reduce a bit the performance of the computations, but it is useful to track if everything is working well). By default |
verbose |
logical, indicates if progress messages are to be printed. By default |
... |
further arguments to be passed to the low level function randomForest.default. |
It returns a RasterStack
object with as many layers as time steps are present in x
. Each one of the layers in the output object has the same spatial resolution and spatial extent as the cov
argument.
Oscar M. Baez-Villanueva, obaezvil@th-koeln.de
Mauricio Zambrano-Bigiarini, mzb.devel@gmail
Juan D. Giraldo-Osorio, j.giraldoo@javeriana.edu.co
Baez-Villanueva, O. M.; Zambrano-Bigiarini, M.; Beck, H.; McNamara, I.; Ribbe, L.; Nauditt, A.; Birkel, C.; Verbist, K.; Giraldo-Osorio, J.D.; Thinh, N.X. (2020). RF-MEP: a novel Random Forest method for merging gridded precipitation products and ground-based measurements, Remote Sensing of Environment, 239, 111610. doi: 10.1016/j.rse.2019.111606. <https://authors.elsevier.com/c/1aKrd7qzSnJWL>.
Hengl, T., Nussbaum, M., Wright, M. N., Heuvelink, G. B., & Gr\"aler, B. (2018). Random forest as a generic framework for predictive modeling of spatial and spatio-temporal variables. PeerJ, 6, e5518.
raster
, stack
, brick
, resample
, rotate
, crop
.
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 36 37 38 39 40 41 | library(rgdal)
library(raster)
data(ValparaisoPPts)
data(ValparaisoPPgis)
data(ValparaisoSHP)
chirps.fname <- system.file("extdata/CHIRPS5km.tif",package="RFmerge")
prsnncdr.fname <- system.file("extdata/PERSIANNcdr5km.tif",package="RFmerge")
dem.fname <- system.file("extdata/ValparaisoDEM5km.tif",package="RFmerge")
CHIRPS5km <- brick(chirps.fname)
PERSIANNcdr5km <- brick(prsnncdr.fname)
ValparaisoDEM5km <- raster(dem.fname)
covariates <- list(chirps=CHIRPS5km, persianncdr=PERSIANNcdr5km,
dem=ValparaisoDEM5km)
# The following code assumes that the region is small enough for neglecting
# the impact of computing Euclidean distances in geographical coordinates.
# If this is not the case, please read the vignette 'Tutorial for merging
# satellite-based precipitation datasets with ground observations using RFmerge'
# without using parallelisation
rfmep <- RFmerge(x=ValparaisoPPts, metadata=ValparaisoPPgis, cov=covariates,
id="Code", lat="lat", lon="lon", mask=ValparaisoSHP, training=1)
# Detecting if your OS is Windows or GNU/Linux,
# and setting the 'parallel' argument accordingly:
onWin <- ( (R.version$os=="mingw32") | (R.version$os=="mingw64") )
ifelse(onWin, parallel <- "parallelWin", parallel <- "parallel")
#Using parallelisation, with a maximum number of nodes/cores to be used equal to 2:
par.nnodes <- min(parallel::detectCores()-1, 2)
rfmep <- RFmerge(x=ValparaisoPPts, metadata=ValparaisoPPgis, cov=covariates,
id="Code", lat="lat", lon="lon", mask=ValparaisoSHP,
training=0.8, parallel=parallel, par.nnodes=par.nnodes)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.