regrid <- function(index, non_uniform_data, target_grid, date,
                   crs_sim = "+proj=utm +zone=31 +ellps=intl +units=m +no_defs") {
  # data.frame and SpatialPointsDataFrame:
  non_uniform_data <- results[results$date == date[index],]
  non_uniform_data <- sp::SpatialPointsDataFrame(non_uniform_data[,c("X", "Y")],
                                              non_uniform_data)
  sp::proj4string(non_uniform_data) <- crs_sim

  regular <- gstat::idw(NO2 ~ 1, non_uniform_data, newdata = target_grid,
                        idp = 2.0, nmax = 4)
  regular <- sp::spTransform(regular, sp::CRS("+proj=longlat"))
  lon <- unique(round(regular@coords[,1],7))
  lat <- unique(round(regular@coords[,2],7))
  proj <- paste(regular@proj4string@projargs, "+no_defs")
  regular <- regular@data$var1.pred
  dim(regular) <- c(lon = 1450, lat = 1644)
  #if (plot == TRUE) {
  #  fields::image.plot(lon, lat, regular, main = "IDW 4 nearest neighbours",
  #                     legend.lab = "NO2 concentration",
  #                     breaks = seq(0, 100, 100/64))
  #}
  return(list(regular = regular, lat = lat, lon = lon))
}
