> d = data.frame(x=runif(100), y=runif(100), Z=rnorm(100))
> coordinates(d)=~x+y
>
> k = krige(formula = Z~1, data=d, locations=~x+y, newdata=d)
Error in `coordinates<-`(`*tmp*`, value = locations) :
setting coordinates cannot be done on Spatial objects, where they have already been set
>
> k = krige(formula = Z~1, locations=d, newdata=d)
[inverse distance weighted interpolation]
That's a simpler example, and actually your solution should work.
With my error
Ni.krig <- krige(formula = Ni~1,
locations = clean.donnees.Ni,
newdata = krig.grid,
model = Ni.vg.fit)
Error in h(simpleError(msg, call)) :
error in evaluating the argument 'obj' in selecting a method for function 'coordinates': trying to get slot "bbox" from an object (class "data.table") that is not an S4 object
there is something strange, as you can see my clean.donnees.Ni is well a S4 object :
> typeof(clean.donnees.Ni)
[1] "S4"