# Accurate Estimation of Air Pollution in Outdoor Routes for Citizens and Decision Making
## 4 Merging Pollution Data over a Grid on the City Map
### Kriging for Spatial Interpolation  
Kriging is a spatial statistical technique that allows the analysis of geolocated information and it is based on spatial autocorrelation. It entails an interpolation approach rooted in Gaussian processes, guided by previous covariances derived from previous measurements. This technique is designed to estimate a value at a given point within a random field [21] by performing a weighted average of known values from the neighbouring points. A fundamental principle underlying Kriging is that, under appropriate prior assumptions, it offers the optimal linear unbiased prediction, relying on covariance assumptions [22]. In Kriging, a value in a location \(x_{1}\) is a realization of \(z(x_{1})\) that is estimated from \(N\) measurements of the random variables \(Z(x_{1}),Z(x_{2}),\ldots,Z(x_{N})\) that are correlated. By assuming stationarity in the random function based on the homogeneity of samples, the correlation between two random variables only depends on their separation, denoted as distance \(h\) (or \(lag\), and it is independent of their location. Thus, the covariance function for the response at two different points \(x_{i},x_{j}\) with \(h=|x_{i}-x_{j}|\) is given by Equation (1) for some function \(c\),  
\[cov[Z(x_{i}),Z(x_{j})]=c(Z(x_{i}),Z(x_{i}+h))=c(h) \tag{1}\]  
It allows us to define the variogram and the co-variogram functions as:  
\[ \begin{split}\gamma(h)&=\frac{1}{2|N(h)|}\cdot \sum_{(i,j)\in N(h)}(Z(x_{i})-Z(x_{j}))^{2}\\ c(h)&=\frac{1}{|N(h)|}\cdot\sum_{(i,j)\in N(h)}(Z( x_{i})-m(h))(Z(x_{j})-m(h))\end{split}  \tag{2}\]  
where \(N(h)\) denotes the pairs of observations \(i,j\) separated by \(h\) and \(m(h)\) is defined as:  
\[m(h)=\frac{1}{2|N(h)|}\cdot\sum_{(i,j)\in N(h)}(Z(x_{i})+Z(x_{j})) \tag{3}\]  
Then, the estimated value is calculated by linear estimation from the observed values and weights as follows:  
\[\hat{Z}(x_{0})=\sum_{i=1}^{N}w_{i}(x_{0})Z(x_{i}) \tag{4}\]  
To calculate these weights \(w_{i}\) in Equation (4), we must keep two criteria, global unbiased and minimal variance of estimation. The first criterion implies that the mean of the estimations must be equal to the mean of the real values. The second criterion determines that the squared deviations of the estimations must be a minimum. Both criteria are applied and solved using Lagrange multipliers. Notice that there are different methods to calculate these weights giving different types of Kriging techniques. From all of them, the most common are Simple Kriging (SK) and Ordinary Kriging (OK). In OK, the global mean is unknown, while in SK, the global mean is known. In our case for the estimation of air pollutants, we use OK. Furthermore, from the set of samples, we need to calculate and model the empirical variogram. The objective of a variogram modelling is to determine the autocorrelation structure of the underlying stochastic process, given by the _nugget effect_, _sill_, and _range_ parameters, as depicted in Figure 3. The _nugget effect_ represents the measurement error at \(\gamma(h)\) for \(h=0\). The _sill_ is the value of \(\gamma(h)\) when \(h\to\infty\) representing the variance of the random field and the _range_ is the distance at which data are no longer auto correlated [22]. As a first approach, the variogram is estimated based on the measured values taken in different locations, and is later replaced by an adjusted model (such as _spherical_, _exponential_, _gaussian_, to name a few).