I have been trying to use hydrokrige function (hydroTSM package) to interpolate rainfall data. For some data it seems to be working fine while I can't make sense of result I am getting for some records. Below are two reproducible examples with and without issue. Any help on how can we we sort this issue (getting result for sample 2 right) would be greatly appreciated.
Thanks a lot
library(raster)
library(hydroTSM)
library(sp)
#Defining coordinate system
CatchmentCRS <- CRS("+proj=utm +zone=45 +datum=WGS84 +units=m +no_defs +ellps=WGS84 +towgs84=0,0,0")
#Specifying the Rain station data
Station <- c('A','B','C','D','E','F','G','H','I','J','K','L')
E <- c(310837,318763,327604,322488,342071,335614,350525,397733,367804,383061,351609,348017)
N <- c(3054360,3033922,3076276,3063420,3052069,3061389,3070430,3018240,2996366,3036835,3024248,3000284)
StationDf <- data.frame(Station,E,N)
#Defining a rectangular catchment
Rectangle1 = Polygon(cbind(c(302699,400595,400595,302699),c(3078295,3078295,2991776,2991776)))
Catchment1 = Polygons(list(Rectangle1), "s1")
Catchment = SpatialPolygons(list(Catchment1), 1:1)
#Rain data set examples
RainDataDf <- data.frame(A=numeric(1),B=numeric(1),C=numeric(1),D=numeric(1),E=numeric(1),F=numeric(1),G=numeric(1),H=numeric(1),I=numeric(1),J=numeric(1),K=numeric(1),L=numeric(1))
#Sample record set 1:
RainDataDf[1,] <- c(1529.05,1619.50,NA,2393.85,NA,1143.70,2223.15,397.10,1745.70,1353.55,2254.80,2287.60)
#Creating named numeric vector
RainTs <- as.numeric(RainDataDf[1,])
names(RainTs) <- c('A','B','C','D','E','F','G','H','I','J','K','L')
#Interpolating rainfall using IDW/Kriging
rain <- hydrokrige(x.ts= RainTs, x.gis=StationDf,
X="E" , Y="N", sname="Station",
type= "cells",
formula=value ~ 1,
subcatchments= Catchment,
p4s= CatchmentCRS,
cell.size= 1000)
However, below generates result that doesn't seem to be correct to me (can see min and max value are not different by much. IDW results for both sample data are fine though (only ordinary kriging results have this issue).
#Sample record set 2
RainDataDf[1,] <- c(1657.100,2212.450,2878.450,2670.450,1255.600,1329.300,2216.679,1246.750,2240.250,1996.800,3703.900,1948.800)
#Creating named numeric vector
RainTs <- as.numeric(RainDataDf[1,])
names(RainTs) <- c('A','B','C','D','E','F','G','H','I','J','K','L')
#Interpolating rainfall using IDW/Kriging
rain <- hydrokrige(x.ts= RainTs, x.gis=StationDf,
X="E" , Y="N", sname="Station",
type= "cells",
formula=value ~ 1,
subcatchments= Catchment,
p4s= CatchmentCRS,
cell.size= 1000)