R sp.predict defining pred.coords and pred.covars

27 Views Asked by At

I have been trying to use sp.predict for kriging. However, I am having difficulties defining my grid for pred.coords and predict.covars. The current analysis provides results in bands that I know are incorrect. Guidance on how to properly define these variables would be appreciated.

borders <- Countyborder

mask <- borders %>% 
  st_bbox() %>% 
  st_as_sfc() %>% 
  st_buffer(5) %>% 
  st_difference(borders) %>% 
  st_as_sf()

mask <- st_transform(mask, 4326)
borders2 <- st_transform(borders, 4326)
mask3 <- as(borders2, 'Spatial')

grd <- makegrid(mask3, n = 1000)
colnames(grd) <- c("x", "y")

grd_pts <- SpatialPoints(
  coords      = grd
)

grd_pts_in <- grd_pts[mask3,]

ggplot(as.data.frame(coordinates(grd_pts))) +
  geom_point(aes(x, y))

pred.coords <- as.matrix(SpatialPoints(grd_pts)@coords)
m <- nrow(pred.coords)
#pred.covars <- cbind(as.matrix(rep(1, nrow(pred.coords))), pred.coords)
pred.covars <- mkMvX(list(matrix(1,m,1), matrix(1,m,1), matrix(1,m,1)))

spPredict(pmfin, start= burn.in, pred.coords = pred.coords, pred.covars = pred.covars)
0

There are 0 best solutions below