Closed udayguntupalli closed 6 years ago
thank you for the issue @udayguntupalli and for providing your R session info
What is the link for the EIA website? I'm not sure what that is. The ncdc functions work with the NCDC API, where you can get a token at https://www.ncdc.noaa.gov/cdo-web/token
@sckott , Thank you for the quick response. https://www.ncdc.noaa.gov/cdo-web/token - I have used the same link as you have posted from the EIA website for the token. Is there a separate token that I need to request for the other datasets ? Despite acquiring the token from this website, I failed at being able to use the ncdc_stations and ncdc_locs functions. Could you help me understand what I am doing wrong ?
I am assuming, I need to pass the token as a header - but unable to find any examples that explain it in R .
Uday
(Sorry, accidentally closed there)
there's a few possibilities.
The token you got isn't somehow recognized by NOAA yet, but will hopefully be soon, i haven't heard of this happening before, but its possible
somehow rnoaa isn't picking up your key. can you try running ncdc_stations(datasetid='GHCND', locationid='FIPS:12017', stationid='GHCND:USC00084289', config=httr::verbose())
and make sure you see your token in the request, you should see a header that looks like
-> GET /cdo-web/api/v2/stations/GHCND:USC00084289?datasetid=GHCND&locationid=FIPS%3A12017 HTTP/1.1
-> Host: www.ncdc.noaa.gov
-> User-Agent: libcurl/7.54.0 r-curl/3.1 httr/1.3.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> token: <your token here>
...
@sckott ,
I ran the exact code that you have provided and I see the token being passed;
ncdc_stations(datasetid='GHCND', locationid='FIPS:12017', stationid='GHCND:USC00084289', config=httr::verbose())
-> GET /cdo-web/api/v2/stations/GHCND:USC00084289?datasetid=GHCND&locationid=FIPS%3A12017 HTTP/1.1
-> Host: www.ncdc.noaa.gov
-> User-Agent: libcurl/7.56.1 r-curl/3.1 httr/1.3.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, /
-> token: my token
->
<- HTTP/1.1 400 Bad Request
Okay, so it sure seems like NOAA isn't recognizing it as an acceptable key
Email ncei.orders@noaa.gov and ask if somehow you're key isn't be recognized as acceptable
@sckott , They gave me a new key and I am able to connect. I intend to use the package to explore the data. Thanks a lot for the great contribution.
Uday
great, glad you sorted it out. sorry about the trouble.
Session Info
```r R version 3.4.3 (2017-11-30) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows >= 8 x64 (build 9200) Matrix products: default locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] rnoaa_0.7.0 jsonlite_1.5 httr_1.3.1 xml2_1.1.1 reshape_0.8.7 plyr_1.8.4 ggplot2_2.2.1 loaded via a namespace (and not attached): [1] Rcpp_0.12.14 bindr_0.1 magrittr_1.5 rappdirs_0.3.1 munsell_0.4.3 colorspace_1.3-2 R6_2.2.2 rlang_0.1.6 hoardr_0.2.0 stringr_1.2.0 [11] dplyr_0.7.4 tools_3.4.3 grid_3.4.3 gtable_0.2.0 digest_0.6.13 lazyeval_0.2.1 assertthat_0.2.0 tibble_1.4.1 bindrcpp_0.2 gridExtra_2.3 [21] purrr_0.2.4 tidyr_0.7.2 curl_3.1 glue_1.2.0 stringi_1.1.6 compiler_3.4.3 pillar_1.0.1 scales_0.5.0 XML_3.98-1.9 lubridate_1.7.1 [31] pkgconfig_2.0.1 ```Hello, First of all thank you for putting in so much work and sharing it. I have installed the rnoaa package and I have received the key after registering on the EIA website. I have saved the key as a .Renviron variable per the recommendation in the documentation .
Sys.setenv(NOAA_KEY = "my-token") Key <- Sys.getenv("NOAA_KEY")
When I try one of the samples provided in the documentation:
stations <- ncdc_stations(datasetid='GHCND', locationid='FIPS:12017', stationid='GHCND:USC00084289',token = Key) ncdc_locs(locationcategoryid='CITY', sortfield='name', sortorder='desc',token = Key)
I repeatedly receive the following error : Error: (400) - The token parameter provided is not valid.
Can you offer any guidance on how to fix this ?
Best Uday