AustralianAntarcticDivision / raadtools

Tools for Synoptic Environmental Spatial Data
http://australianantarcticdivision.github.io/raadtools/
24 stars 3 forks source link

unable to find an inherited method for function ‘extract’ for signature ‘"function", "tbl_df" #116

Closed dahliasan closed 2 years ago

dahliasan commented 2 years ago

Hi Mike,

I'm suddenly getting an error when I run the following code:

d$sst <- extract(readsst, d[, c("lon", "lat", "date")])

corresponding error:

Error in (function (classes, fdef, mtable)  : 
  unable to find an inherited method for function ‘extract’ for signature ‘"function", "tbl_df"’

I tried converting the tbl_df to a regular data.frame - still didn't work.

However extract works when I do it for topo: d$topo <- extract(readtopo("etopo1"), d[, c("lon", "lat")])

Not sure why adding a date column would lead to that error.

Hope you can help, thanks!

mdsumner commented 2 years ago

I think you need raster::extract(readsst, d[, c("lon", "lat", "date")]) or possibly raadtools::extract(readsst, d[, c("lon", "lat", "date")])

HTH!

dahliasan commented 2 years ago

Thanks Mike! It didn't work. But I found a way to get around it by looping through dates. All good now :)