I am trying to interpolate a raster using ordinary kriging. When I use the data from meuse to try the model, I get an interpolated output. However, when I run the code with my own data, the interpolation looks exactly like my original raster.
Here is an example of my data. As I said, I am providing this as data(meuse) is apparently computing right.
aggregated_raster_df <- data.frame (x = c(16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875, 16.125, 16.375, 16.625, 16.875, 17.125,
17.375, 17.625, 17.875), y = c(-23.125, -23.125, -23.125, -23.125,
-23.125, -23.125, -23.125, -23.125, -23.375, -23.375, -23.375,
-23.375, -23.375, -23.375, -23.375, -23.375, -23.625, -23.625,
-23.625, -23.625, -23.625, -23.625, -23.625, -23.625, -23.875,
-23.875, -23.875, -23.875, -23.875, -23.875, -23.875, -23.875,
-24.125, -24.125, -24.125, -24.125, -24.125, -24.125, -24.125,
-24.125, -24.375, -24.375, -24.375, -24.375, -24.375, -24.375,
-24.375, -24.375, -24.625, -24.625, -24.625, -24.625, -24.625,
-24.625, -24.625, -24.625, -24.875, -24.875, -24.875, -24.875,
-24.875, -24.875, -24.875, -24.875), sum = c(26, 24, 33, 10,
20, 7, 4, 0, 100, 27, 54, 33, 100, 8, 14, 39, 100, 90, 37, 3,
4, 1, 3, 3, 100, 37, 30, 0, 1, 10, 8, 24, 79, 100, 11, 0, 2,
8, 79, 100, 100, 100, 5, 16, 1, 3, 1, 100, 100, 100, 3, 20, 18,
5, 5, 85, 100, 33, 4, 72, 7, 6, 5, 12))
Here is my code:
extent <- c(16,18,-25,-23)
blankRaster <- rast(ext(extent), res=.25)
v <- variogram(sum~1, ~x+y, data=aggregated_raster_df)
mv <- fit.variogram(v, vgm(1000, "Exp", 3, 1))
gOK <- gstat(NULL, "sum", sum~1, aggregated_raster_df, locations=~x+y, model=mv)
OK <- interpolate(blankRaster, gOK, xyNames = c("x", "y"))
This is the output, where sum.original (the original raster) looks exactly the same as sum.pred (the output from the interpolation)