I want to perform ordinary kriging of temperature (UTCI) data in Nigeria with sf and gstat packages. However, after fitting the variogram model and creating a grid for the region, the krige function returns this error:
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘krige’ for signature ‘"formula", "sfc_POINT"’ What am I doing wrong? Here is my code: library(gstat) library(sf) sf_data <- st_as_sf(x = data, coords = c("longitude", "latitude"), crs = 4326) #VARIOGRAM vgm_utci <- variogram(UTCI~1, sf_data) utci_fit <- fit.variogram(vgm_utci, vgm("Mat"), fit.kappa = TRUE) #CREATE GRID nigeria <- read_sf("./Igismap/Nigeria_Boundary.shp") nigeria <- nigeria$geometry nigeria.grid <- nigeria %>% st_make_grid(cellsize = 0.1, what = "centers") %>% st_intersection(nigeria) #UTCI ORDINARY KRIGING utci_krig <- krige(formula = sf_data$UTCI ~ 1, nigeria.grid, model = utci_fit) When plotted, the grid and the variogram model look fine. I have attached data and shapefile. Thank you so much in advance, Nicola ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.