So I have two datasets with latitude, longitude and depth in them and I am trying to krige them so that I create a very high resolution bathymetric map for a study I am conducting. I am using the depth information that I collected to construct the variogram and as the "locations" argument in the krige command. The prediction frame is a grid of coordinates covering the entire area, I want to fill this grid with depth date so I can create a raster and eventually use it to map the seabed.
My issue is that for some reason, every cell in the prediction frame is returning an identical value and I can't figure out why as the code all runs without error. I have been playing around with the fit.variogram command as there were some previous issues, and it is a bit fussy with initial values in terms of psill and range, especially if i change the nugget, it often gives the warning "Singular model in variogram fit". But it does still result in a reasonable looking variogram so I'm not sure if that would affect the kriging output.
Here is the code I used:
coordinates(site1_depth)= ~x+y
vg<-variogram(depth~1, data=site1_depth, cutoff=0.01, width=0.0001)
fit.vg <- fit.variogram(vg, model = vgm(model = "Sph",nugget=0))
fittedValues <- variogramLine(fit.vg, maxdist = 0.01, n = 60)
par(bg = "white")
plot(vg$dist, vg$gamma, xlab = "Distance", ylab = "Semivariance")
lines(fittedValues, lwd=2)
coordinates(site1_coords)= ~x+y
kriged_data <- krige(depth ~ 1, locations=site1_depth, site1_coords, model=fit.vg)
site1_dem <- kriged_data1@data["var1.pred"]