I am trying to perform universal kriging in R using the gstat package and running into the following error:

krige(formula = CDD_LT_stC ~ Imperv1km + Elev_new, locations = sp.cal_data, newdata = sp.studygrid, model = modelfit, nmax = 200)

Error in eval(predvars, data, env) : object 'Imperv1km' not found

Any ideas why is this happening and how to fix this?

However, I was able to perform ordinary kriging with:

krige(formula = CDD_LT_stC ~ 1, locations = sp.cal_data, newdata = sp.studygrid, model = modelfit, nmax = 200)

closed as unclear what you're asking by Spacedman, LaughU, Jochen Schwarze, whyzar, xunilk Nov 13 '18 at 0:24

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    What is in your sp.cal_data data frame? It is saying there is no column called Imperv1km. Hard for us to answer without more details or a copy of your data. – Spacedman Nov 12 '18 at 7:06
  • @Spacedman It's a "SptatialPointsDataFrame" and does include the column Imperv1km as well as the Elev_new. As I mentioned, the code worked if I use the ordinary kriging (i.e., formula = CDD_LT_stC ~ 1) but isn't working when I am using universal kriging (i.e., formula = CDD_LT_stC ~ Imperv1km + Elev_new). In both cases, the dataset are the same. – Saad Nov 12 '18 at 15:37
  • Edit your post to show some information about sp.cal_data - at a very minimum the output of summary on it. – Spacedman Nov 12 '18 at 17:32
  • And are you using the same modelfit object? – Spacedman Nov 12 '18 at 17:34
  • And do those columns exist in your newdata? – Spacedman Nov 12 '18 at 17:36