[R] Error with sf ordinary kriging after creating grid

Bert Gunter bgunter@4567 @end|ng |rom gm@||@com
Thu Aug 13 14:20:26 CEST 2020


You should post on r-sig-geo, not here. The specific expertise you seek is
much more likely to be found there.

Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Thu, Aug 13, 2020 at 4:09 AM Nicola Gambaro <nicola using gambaro.co.uk> wrote:

> 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 using 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.
>

	[[alternative HTML version deleted]]



More information about the R-help mailing list