如何根据特定的经度和纬度提取历史天气数据?

时间:2019-04-07 12:18:13

标签: r weather

我需要根据欧洲的特定位置(所有位置都在海中)每月提取2001年至2018年的历史天气数据。我将经度和纬度存储在单独的列中:

longitude    latitude

55.2000       6.8500
52.6450       1.7870
53.1350       1.1470
55.3430       10.95580

我查看了R中的RNCEP软件包,该软件包存储天气数据。但是要提取它,我必须插入纬度和经度的间隔(例如,从0到60),这将获得纬度和经度的气象数据,增量为2.5。如何提取所需的精确纬度和经度?

这是以2.5增量提取天气数据的代码。

#Define limits for latitude and longitude
min_lat <- min(data$latitude, na.rm = TRUE)
max_lat <- max(data$latitude, na.rm = TRUE)

min_lon <- min(data$longitude, na.rm = TRUE)
max_lon <- max(data$longitude, na.rm = TRUE)

# define arguments for latitude and longitude
lat_range <- c(min_lat, max_lat)
lon_range <-c(min_lon, max_lon)

# get monthly air temperature between 2001 and 2018
weather <- NCEP.gather(variable = "air.sig995", level = "surface", months.minmax = c(1,12),
                       years.minmax = c(2001,2018), lat.southnorth =lat_range,
                       lon.westeast = lon_range)

# dimensions (obs. at time 00:00, 6:00, 12:00, 18:00 each day)
dim(weather) #creates 3 dimensions [lat, lon, time]

# extract date and time based on created weather dataset
date_time <- dimnames(weather)[[3]]
# format UTC date
date_time <- ymd_h(date_time)

# extract longitude & latitude based on created weather dataset
lat <- dimnames(weather)[[1]] # in increments of 2.5
lon <- dimnames(weather)[[2]] # in increments of 2.5

#Calculate the mean daily air temp. of the different times of day
w <- NCEP.aggregate(weather, YEARS = TRUE, MONTHS = TRUE, HOURS = FALSE, fxn='mean')

#Visualize temperature as heatmap for 1 day
NCEP.vis.area(w, layer = 1, show.pts = TRUE, draw.contours = TRUE, cols = heat.colors(64), transparency = 0.4)

我的结果只是提取整个区域的历史天气数据,设置经度和纬度的范围。但是我需要根据所有年份(2001年至2018年)每个月的经度和纬度列来确定确切位置的天气条件(例如该月的平均温度)。是否可以使用RNCEP软件包执行此操作?还是我可以尝试其他什么选择?

最终结果应与此类似:

longitude    latitude   month  year  temperature

55.2000       6.8500     1     2001    20
55.2000       6.8500     2     2001    20
55.2000       6.8500     3     2001    20

...

55.2000       6.8500     1     2018    20

...

52.6450       1.7870     2

...

我愿意接受任何可能更接近解决方案的建议,而不仅仅是最终解决问题的建议。谢谢。

1 个答案:

答案 0 :(得分:0)

使用RNCEP无法获得更详细的信息。该模块正在从NCEP/NCAR Reanalysisreanalysis 2数据集中进行查询,并在这些站点中进行挖掘,看起来表面层数据Reanalysis 2 / { {3}}。