首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在有经纬度信息的情况下利用GET将天气资料输入R?

如何在有经纬度信息的情况下利用GET将天气资料输入R?
EN

Stack Overflow用户
提问于 2018-06-21 08:15:05
回答 1查看 0关注 0票数 0

我正在R中建立一个程序,如果我提供纬度和经度值的话,我可以得到一个位置的一些天气信息。我想使用http或HTTR包并使用GET函数。有人能向我展示使用API如何实现这一任务的R代码吗?

EN

回答 1

Stack Overflow用户

发布于 2018-06-21 18:12:52

如果你访问Weather Underground站点并获取API密钥(https://www.wunderground.com/weather/api/),则可以使用rwunderground封装来封装所需的所有低级httr功能以获取天气状况。例如,

代码语言:javascript
复制
library(rwunderground)
wx <- conditions(set_location(lat_long="40,-104"))

这将首次要求你输入你的API密钥。这将是类似的,dxxxxd3000b5xxxx但它将是唯一的注册。每分钟和每天查询都有限制。以下是你可以访问的变量:

代码语言:javascript
复制
> wx <- conditions(set_location(lat_long="40,-104"))
[1] "Requesting: 
http://api.wunderground.com/api/d7000d3860b5bf50/conditions/q/40,-104.json"
[1] "Conditions for: Wiggins, CO"
[1] "Observed at: Fort Morgan, Colorado"
[1] "Station id: KCOWIGGI11"
[1] "Time: Last Updated on June 17, 6:19 PM MDT"

> str(wx)
Classes ‘tbl_df’, ‘tbl’ and 'data.frame':   1 obs. of  15 variables:
 $ weather      : Factor w/ 1 level "Rain": 1
 $ temp         : num 61
 $ pct_humidity : num 92
 $ wind_spd     : num 8.7
 $ wind_spd_gust: num 11.4
 $ wind_dir     : Factor w/ 1 level "NE": 1
 $ pressure     : num 30
 $ dew_pt       : num 59
 $ heat_index   : num NA
 $ windchill    : num NA
 $ feelslike    : num 61
 $ visibility   : num 10
 $ UV           : num 0
 $ precip_1hr   : num 0.05
 $ precip_today : num 0.15
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100005479

复制
相关文章

相似问题

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