I am trying to apply kriging to interpolate the air pollution concentration (target variable) When I run the krige function as below, R return an error.
RSPAVE is the target variable; air is the dataset the contains the RSPAVE; TPU is the shapefile
k.o <- krige(RSPAVE ~1, locations=air, newdata=TPU, model=m.RSPAVE.f)
Error in predict.gstat(g, newdata = newdata, block = block, nsim = nsim, :
gstat: value not allowed for: block kriging for long-lat data undefined
It is probably because my grid data is a shapefile. But I don't want block kriging, how can I turn the polygon to point, and apply ordinary kriging?
Thank you very much!
Assuming
RSPAVE
is a SpatialPolygonsDataFrame` and that you want to krige based on geographical centroids, this should work:That converts it to a point layer.
Then same as before: