r-spatial / gstat

Spatial and spatio-temporal geostatistical modelling, prediction and simulation
http://r-spatial.github.io/gstat/
GNU General Public License v2.0
194 stars 49 forks source link

krige.cv fails with the message 'no simple feature geometry column present' #122

Closed alexyshr closed 1 year ago

alexyshr commented 1 year ago

I hope everything is going well!

Sorry for not providing a reproducible example.

I have a valid point sf (ea_sf) with a spatial column (geometry). The interpolation grid is a proper stars object (grd). I was able to do krige with them. But the krige.cv sends this error: Error in st_sf(x, ..., agr = agr, sf_column_name = sf_column_name) : no simple features geometry column present.

The line that sent the error is: KO.wav.cv <- gstat::krige.cv(co2~1, ea_sf, grd, model=m.f.wav, nfold=nrow(ea_sf)).

This line works ok: KO.wav.cv <- gstat::krige.cv(co2~1, loc=~ x+y, data=ea2, model=m.f.wav, nfold=nrow(ea2)).

Thank you Dr. Edzer!

edzer commented 1 year ago

Hi Alexys! For krige.cv you should not pass on a grd stars object, as you only iterate over the points in ea2. Does that help?

Many regards, from geopython 2023 this time.

alexyshr commented 1 year ago

Hi Dr. Edzer. For sure you will bring lots of new ideas from the Python world to R. Please don't leave R aside. I am following your approach in your book https://r-spatial.org/book/13-Geostatistics.html. I just want to use only sf and stars with gstat. I solved the problem using a data.frame with x and y columns (last line), but it is not that cool!