1

我有latitude,longitudedate.

问:有没有一种简单的方法可以air_temperature从那里获得最近的测量值?

data$air_temperature = fetch_nearest_parameter(latitude = lat, longitude = lon, date = mydate, parameter = "air_temperature")

解决该任务的一个很好的辅助功能是:选择在我给定日期提供 air_temperature 的纬度/经度最近的车站。

这是我最近的尝试(不是真的有效)如下。第 1 步:选择最近的 50 个站点 第 2 步:对于所有站点,尝试获取我给定日期的 air_temperature。第3步:希望至少有1个匹配然后使用这个。这种方法的问题:第 3 步中从来没有一个匹配项。

lat_lon_df <- data.frame(id = c("1"),
                         latitude = c(-33.8675),
                         longitude = c(151.2070))


# fetch 50 nearest stations
nearby_stations <- meteo_nearby_stations(lat_lon_df = lat_lon_df, limit=50,  var = c("TMAX"), 
                                          station_data = station_data, year_min=2000, year_max=2017)
ns <- do.call(rbind, lapply(nearby_stations, data.frame, stringsAsFactors=FALSE))

mydate = 20160503
# check all 50 stations for air_temperature at my given date
# the column 'xxx' always ends up being filled 100 % with NAs
ns$xxx = lapply(ns$id, function(x) { return(tryCatch(coops_search(station_name = x, begin_date=mydate, end_date=mydate, product="air_temperature"), error=function(e) NA)) })
4

0 回答 0