我碰巧找到了
lutz
tz_lookup_coords()
. 使用此函数可以通过两种方式设置方法。一个是
method = "fast"
另一个是
method = "accurate"
library(lutz)
set.seed(111)
data <- data.table(latitude=sample(seq(47,52,by=0.001), 1000000, replace = TRUE),
longitude=sample(seq(8,23,by=0.001), 1000000, replace = TRUE))
system.time(data[, timezone := tz_lookup_coords(lat = latitude, lon = longitude, method = "fast")])
#user system elapsed
#6.46 3.42 9.92
#Warning message:
#Using 'fast' method. This can cause inaccuracies in timezones
#near boundaries away from populated ares. Use the 'accurate'
#method if accuracy is more important than speed.
system.time(data[, timezone := tz_lookup_coords(lat = latitude, lon = longitude, method = "accurate")])
# user system elapsed
#154.44 0.18 154.93