首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >weatheR数据包

weatheR数据包
EN

Stack Overflow用户
提问于 2017-07-13 10:50:12
回答 2查看 589关注 0票数 0

使用weatheR包时,我需要来自特定站点的数据,所以我尝试使用getStationByID funciont。车站是格罗塔格利,在我的station.list df中,它的美国空军id是163240:

代码语言:javascript
复制
require(devtools)
install_github("mpiccirilli/weatheR")
require(weatheR)
station.list <- allStations()

station.list %>% filter(USAF==163240)


USAF     WBAN       NAME   CTRY   STATE    ICAO    LAT    LON      ELEV    BEGIN      END 
 163240   99999  GROTTAGLIE  IT           LIBG    40.518    17.403    65.5    19430927 20170710

如果我启动这个游戏

代码语言:javascript
复制
grottaglie<- getStationByID(stationID = '163240',station.list = station.list, begin = 2013, 2016)

我得到了

名称错误(combined.list)i <- keysi:‘name’属性1必须与向量长度相同

有什么建议吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-07-13 16:40:06

weatheR包似乎是一个废弃的项目。

getStationByID函数的代码中可以看出,它无法工作。

修改后的getStationByID是可用的这里

下载此文件,并将其保存在名为mygetStationByID.r的工作目录中。

然后,使用以下代码:

代码语言:javascript
复制
require(weatheR)
station.list <- allStations()

# Load the modified version of getStationByID   
source("mygetStationByID.r")
# The structure of the fixed-width files 
# downloaded from ftp://ftp.ncdc.noaa.gov/pub/data/noaa/
col.width <- c(4,6,5,8,4,1,6,7,5,5,5,4)
# Column names
col.names <- c("TOT", "USAF", "WBAN", "DATE", "TIME", "DATASOURCE",
 "LAT","LON","CODE","ELEV.DIM","CALL.LETTER","QLT.CTRL")

grottaglie <- mygetStationByID(stationID = 163240,
             station.list = station.list, begin = 2013, end=2016)

str(grottaglie)
# List of 2
#  $ dl_status   :'data.frame':   4 obs. of  4 variables:
#   ..$ File  : chr [1:4] "163240-99999-2013.gz" "163240-99999-2014.gz" "163240-99999-2015.gz" "163240-99999-2016.gz"
#   ..$ Status: chr [1:4] "Failed" "Failed" "Failed" "Failed"
#   ..$ City  : chr [1:4] "Grottaglie, Italy" "Grottaglie, Italy" "Grottaglie, Italy" "Grottaglie, Italy"
#   ..$ rank  : num [1:4] 1 1 1 1
#  $ station_data:List of 1
#   ..$ Grottaglie_163240:'data.frame':   19264 obs. of  12 variables:
#   .. ..$ TOT        : int [1:19264] 126 126 138 137 145 145 145 137 89 89 ...
#   .. ..$ USAF       : int [1:19264] 163240 163240 163240 163240 163240 163240 163240 163240 163240 163240 ...
#   .. ..$ WBAN       : int [1:19264] 99999 99999 99999 99999 99999 99999 99999 99999 99999 99999 ...
#   .. ..$ DATE       : int [1:19264] 20130101 20130101 20130101 20130101 20130101 20130101 20130101 20130101 20130101 20130101 ...
#   .. ..$ TIME       : int [1:19264] 650 750 850 950 1050 1250 1350 1450 1550 1650 ...
#   .. ..$ DATASOURCE : int [1:19264] 4 4 4 4 4 4 4 4 4 4 ...
#   .. ..$ LAT        : num [1:19264] 40.5 40.5 40.5 40.5 40.5 ...
#   .. ..$ LON        : int [1:19264] 17400 17400 17400 17400 17400 17400 17400 17400 17400 17400 ...
#   .. ..$ CODE       : Factor w/ 2 levels "FM-15","FM-16": 1 1 1 1 1 1 1 1 1 1 ...
#   .. ..$ ELEV.DIM   : int [1:19264] 69 69 69 69 69 69 69 69 69 69 ...
#   .. ..$ CALL.LETTER: Factor w/ 2 levels "99999","LIBG ": 2 2 2 2 2 2 2 2 2 2 ...
#   .. ..$ QLT.CTRL   : Factor w/ 1 level "V020": 1 1 1 1 1 1 1 1 1 1 ...

# Table by years 
table(as.numeric(substr(grottaglie$station_data[[1]]$DATE, 1, 4)))
# 2013 2014 2015 2016 
# 4866 4816 4794 4788

我希望它能帮到你。

注:如果代码在第一次运行时生成错误消息,请尝试重新运行它。

票数 1
EN

Stack Overflow用户

发布于 2017-07-13 14:31:44

您可以使用rnoaa

代码语言:javascript
复制
install.packages("rnoaa")
library(rnoaa)
(res <- isd(usaf=163240, wban=99999, year=1986))
#> # A tibble: 7,364 x 78
#>    total_chars usaf_station wban_station     date  time date_flag latitude longitude type_code elevation
#>          <chr>        <chr>        <chr>    <chr> <chr>     <chr>    <chr>     <chr>     <chr>     <chr>
#>  1        0058       163240        99999 19860101  0032         4   +40517   +017400     FM-15     +0069
#>  2        0058       163240        99999 19860101  0100         4   +40517   +017400     FM-15     +0069
#>  3        0058       163240        99999 19860101  0208         4   +40517   +017400     FM-15     +0069
#>  4        0058       163240        99999 19860101  0308         4   +40517   +017400     FM-15     +0069
#>  5        0058       163240        99999 19860101  0408         4   +40517   +017400     FM-15     +0069
#>  6        0074       163240        99999 19860101  0508         4   +40517   +017400     FM-15     +0069
#>  7        0074       163240        99999 19860101  0610         4   +40517   +017400     FM-15     +0069
#>  8        0074       163240        99999 19860101  0710         4   +40517   +017400     FM-15     +0069
#>  9        0074       163240        99999 19860101  0810         4   +40517   +017400     FM-15     +0069
#> 10        0074       163240        99999 19860101  0910         4   +40517   +017400     FM-15     +0069
#> # ... with 7,354 more rows, and 68 more variables: call_letter <chr>, quality <chr>,
#> #   wind_direction <chr>, wind_direction_quality <chr>, wind_code <chr>, wind_speed <chr>,
#> ...
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45078487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档