Why negative value in krigging of rainfall?

Hello,
As I am spatially interpolating rainfall data using the kriging method, I found negative values as provided below.

suppressPackageStartupMessages({
  library(tmap)
  library(tidyverse)
  library(rgdal)
  library(rgeos)
  library(spatstat)  
  library(maptools)  
  library(raster)    
  library(gstat) 
  library(sp)    
  library(gsheet)
})
P_month=gsheet2tbl('https://docs.google.com/spreadsheets/d/1rXB9rG4aRX8Hzyc_O97QcAII9AsiZDlgQ-1JsnMf6ww/edit?usp=sharing')
coordinates(P_month) <- ~lon+lat
proj4string(P_month) <- CRS("+init=epsg:28992")
States=readRDS(url("https://biogeo.ucdavis.edu/data/gadm3.6/Rsp/gadm36_USA_1_sp.rds","rb"))
W  <- States %>% 
  subset(NAME_1%in%c("Alabama","Arkansas", "Florida", "Georgia", "Kentucky", "Louisiana", "Mississippi","Tennessee"))
P_month@bbox <- W@bbox
th  <-  as(dirichlet(as.ppp(P_month)), "SpatialPolygons")
proj4string(th) <- proj4string(P_month)
grd              <- as.data.frame(spsample(P_month, "regular", n=1000000))
names(grd)       <- c("X", "Y")
coordinates(grd) <- c("X", "Y")
gridded(grd)     <- TRUE 
fullgrid(grd)    <- TRUE  
proj4string(P_month) <- proj4string(P_month) 
proj4string(grd) <- proj4string(P_month)
P_month$X <- coordinates(P_month)[,1]
P_month$Y <- coordinates(P_month)[,2]
f.1 <- as.formula(rain ~ X + Y) 
var.smpl <- variogram(f.1, P_month, cloud = FALSE)
dat.fit  <- fit.variogram(var.smpl, vgm(c("Exp", "Sph", "Gau", "Mat")))


dat.krg <- krige( f.1, P_month, grd, dat.fit)
r.m <- mask(raster(dat.krg), W)
plot(var.smpl, dat.fit)

tm_shape(r.m) +tm_raster(n=5, midpoint = NA)

I assume one of the main reasons is due to the warning from

> dat.fit  <- fit.variogram(var.smpl, vgm(c("Exp", "Sph", "Gau", "Mat")))
Warning messages:
1: In fit.variogram(object, x, fit.sills = fit.sills, fit.ranges = fit.ranges,  :
  No convergence after 200 iterations: try different initial values?
2: In fit.variogram(object, x, fit.sills = fit.sills, fit.ranges = fit.ranges,  :
  No convergence after 200 iterations: try different initial values?
3: In fit.variogram(object, x, fit.sills = fit.sills, fit.ranges = fit.ranges,  :
  No convergence after 200 iterations: try different initial values?

I will be using multiple data with a function. So, changing initial values every time won't be feasible.
So, How can I avoid getting negative values of interpolated rainfall?

A krige is a spatial interpolation. It doesn't know that the data is not supposed to be negative. One solution could be to work with transformed data, e.g. z = log(rainfall + eps) where eps is a small number, maybe equal to the minimum non-zero rainfall value. Then untransform after kriging z to get rainfall = pmax(exp(z) - eps, 0).

In NZ we have a national rainfall interpolation model. You read read about it here and it other papers:
https://www.researchgate.net/publication/242572418_Analysis_of_the_Spatial_Interpolation_Error_associated_with_Maps_of_Median_Annual_Climate_Variables

1 Like

If your data has a low frequency trend, that can cause issues with kriging. Removing a trend (the drift) with a low order polynomial ( a plane) is often helpful.

[quote="meitei, post:1, topic:125737"]
proj4string(P_month) <- CRS("+init=epsg:28992")

Change to CRS("+init=epsg:4326") , being same crs as your States object . For me it then runs OK.

JW

1 Like