Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 天气数据包_R_Api - Fatal编程技术网

R 天气数据包

R 天气数据包,r,api,R,Api,使用weatheR软件包,我需要特定站点的数据,所以我尝试使用getStationByID函数。 该站为Grottagile,在我的站中,其USAF id为163240: require(devtools) install_github("mpiccirilli/weatheR") require(weatheR) station.list <- allStations() station.list %>% filter(USAF==163240) USAF WBAN

使用weatheR软件包,我需要特定站点的数据,所以我尝试使用getStationByID函数。 该站为Grottagile,在我的站中,其USAF id为163240:

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
require(devtools)
安装github(“mpiccirilli/weatheR”)
要求(天气)
station.list%过滤器(USAF==163240)
美国空军WBAN名称中央国家民航组织LAT LON ELEV开始结束
163240 99999格罗塔格利IT LIBG 40.518 17.403 65.5 19430927 20170710
如果我启动函数

grottaglie<- getStationByID(stationID = '163240',station.list = station.list, begin = 2013, 2016)

grottagile您可以使用
rnoaa

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>,
#> ...
install.packages(“rnoaa”)
图书馆(rnoaa)
(分辨率:7364 x 78)
#>总字符usaf站wban站日期时间日期标志纬度经度类型代码高程
#>                                                       
#>10058 163240 99999 19860101 0032 4+40517+017400 FM-15+0069
#>20058 163240 99999 19860101 0100 4+40517+017400 FM-15+0069
#>30058 163240 99999 19860101 0208 4+40517+017400 FM-15+0069
#>40058 163240 99999 19860101 0308 4+40517+017400 FM-15+0069
#>50058 163240 99999 19860101 0408 4+40517+017400 FM-15+0069
#>6 0074 163240 99999 19860101 0508 4+40517+017400 FM-15+0069
#>70074 163240 99999 19860101 0610 4+40517+017400 FM-15+0069
#>80074 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
#>#…增加7354行,增加68个变量:呼叫字母、质量、,
#>风向、风向、质量、风码、风速、,
#> ...

您可以使用
rnoaa

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>,
#> ...
install.packages(“rnoaa”)
图书馆(rnoaa)
(分辨率:7364 x 78)
#>总字符usaf站wban站日期时间日期标志纬度经度类型代码高程
#>                                                       
#>10058 163240 99999 19860101 0032 4+40517+017400 FM-15+0069
#>20058 163240 99999 19860101 0100 4+40517+017400 FM-15+0069
#>30058 163240 99999 19860101 0208 4+40517+017400 FM-15+0069
#>40058 163240 99999 19860101 0308 4+40517+017400 FM-15+0069
#>50058 163240 99999 19860101 0408 4+40517+017400 FM-15+0069
#>6 0074 163240 99999 19860101 0508 4+40517+017400 FM-15+0069
#>70074 163240 99999 19860101 0610 4+40517+017400 FM-15+0069
#>80074 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
#>#…增加7354行,增加68个变量:呼叫字母、质量、,
#>风向、风向、质量、风码、风速、,
#> ...

天气计划似乎是一个废弃的项目。
查看
getStationByID
函数的代码,可以发现它无法工作。
可使用修改后的
getStationByID

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

然后,使用以下代码:

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
require(天气)

station.list天气包似乎是一个废弃的项目。
查看
getStationByID
函数的代码,可以发现它无法工作。
可使用修改后的
getStationByID

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

然后,使用以下代码:

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
require(天气)

station.list
rnoaa
是积极维护的,有很多贡献者-仅供参考您的rnoaa是一个很棒的软件包!关于海拔或温度等变量格式,我有一个问题:为什么我会得到“+0020”这样的值?我如何解释它?@andriatz so
rnoaa
是许多NOAA数据集的包装器,所以我们首先关注的是如何获取数据并做好这一点。然后关注数据格式的微调,等等。对于ISD数据,我们正在变得更好,我们有一个sep.pakcage来解析ISD数据b/c,解析起来太可怕了——这可能是一个好的pl提出有关格式问题的ace
rnoaa
得到了积极维护,而且有很多贡献者-仅供参考,rnoaa是一个很棒的软件包!我对高程或温度等变量格式有一个问题:为什么我会得到“+0020”这样的值?我如何解释它?@andriatz so
rnoaa
是许多NOAA数据集的包装器,所以我们首先关注的是如何获取数据并做好这一点。然后关注数据格式的微调,等等。对于ISD数据,我们正在变得更好,我们有一个sep.pakcage来解析ISD数据b/c,解析起来太可怕了——这可能是一个好的place提出有关格式化的问题我刚刚在github页面上打开了一个问题。包创建者回答说他将处理iti。我刚刚在github页面上打开了一个问题。包创建者回答说他将处理它