0

I have a dataset with observations and I need to interpolate it over the grid. I used idw function from gstat package. It makes interpolation but leaves some values as NA. I also tried interp funtion from akima, specializing extrap=TRUE, but it created unrealistic values. Have anybody an idea, how I could fulfill these missing values? Code is below:

winter1 <- winter
winter1$x <- winter1$Lon
winter1$y <- winter1$Lat
coordinates(winter1) = ~x + y
dx <- as.numeric(c(9,30.5))
dy <- as.numeric(c(53.8,66))
grd <- expand.grid(x = seq(from = dx[1], to = dx[2], by = 0.1), y = seq(from = dy[1], to = dy[2], by = 0.1))
coordinates(grd) <- ~x + y 
winter_idw <- idw(formula = winter$Secchi ~ 1, locations = winter1, newdata = grd)
winter_idw <- as.data.frame(winter_idw) 
world <- ne_countries(scale = "medium", returnclass = "sf")
  class(world)
  rng = range(c(0,10))
  p <- ggplot(data = world)+
    geom_raster(data = v, mapping=aes(x = x, y = y, fill=var1.pred))+
    scale_fill_gradient2(low = "blue",
                         mid = "yellow",
                         high = "red",
                         breaks=seq(0,10,2),
                         midpoint=5,
                         limits=c(floor(rng[1]), ceiling(rng[2])))+
    borders("world", colour="black",xlim = c(9,30.5), ylim = c(53.8,66))+
    geom_sf(fill="antiquewhite") +
    coord_sf(xlim=c(9,30.5), ylim=c(53.8,66))+
    theme(plot.title = element_text(hjust = 0.5))

I get such a map: just a big area of missing data

Thank you in advance for your help!

  • This is more of a data modeling question than a programming question. What assumptions do you want to make about your data in order to do the imputation? Seems like this might be a better question for [stats.se] or maybe [gis.se] – MrFlick Mar 30 '20 at 20:27
  • @MrFlick, got it, thank you for your answer. – Alina Lerner Mar 31 '20 at 17:45

0 Answers0