imputeTSRFsp: Spatio-temporal interpolation method

Description Usage Arguments Examples

View source: R/imputeTSRFsp.R

Description

This function is a package created based on the function of 'imputeTS', 'ranger' packages algorithm After creating all the time data for each point by using the imputeTS package, create the randomForest model except when the target variable is missing. Then, based on the data interpolated by b KalmanFilter method, it is used as test data of the RandomForest model to finally produce the data. Based on the produced data, grid data is generated using the Spatial RandomForest model.

Usage

1
2
3
4
5
6
imputeTSRFsp(
  full_df,
  grid.dist,
  station_unique_name = c("alt", "station"),
  date_col = "date"
)

Arguments

'full_df'

is a missing material with location and time information.

Examples

 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
output=imputeTSRFsp(full_df, grid.dist,station_unique_name=c('alt','station'))

df.grid0=expand.grid(seq(min(station@bbox[1,1]),max(station@bbox[1,2]),len=100),
seq(min(station@bbox[2,1]),max(station@bbox[2,2]),len=100))
colnames(df.grid0)=c('lon','lat')

df_pixel0<- sp::SpatialPixelsDataFrame(points = df.grid0[,c('lon','lat')], data = df.grid0)
pred.grid=GSIF::buffer.dist(station,df_pixel0,classes=as.factor(1:nrow(station)))

for(i in colnames(pred.grid@data)){
  pred.grid@data[,i]<-NULL
  }

  pred.grid@data=output$Grid$rh@data

  GADM=raster::getData('GADM', country='KOR', level=1)
  srtm1 <- raster::getData ( 'SRTM', lon = 128, lat = 36)
  srtm2 <- raster::getData ( 'SRTM', lon = 128, lat = 34)
  srtm3=raster::merge(srtm1,srtm2)

  dir.create("examples")
  animation::saveGIF({
      for(i in names(output$Grid$ws)[1:100]){
          message(i)
          raster::plot(srtm3,legend=F,col=0,xlim=c(125,131),ylim=c(33.2,38),main=i,cex=2)
          raster::plot(raster::raster(pred.grid[i]),main=i,cex.main=2,zlim=c(4,100),
          alpha=.9,add=T,col= rev(cm.colors(255)))
        }
   }, movie.name = paste0(getwd(),"/examples/rh.gif"), interval = 0.1)

qkdrk7777775/imputeTSRFsp documentation built on Aug. 10, 2020, 4:56 a.m.