ropensci / rnoaa

R interface to many NOAA data APIs
https://docs.ropensci.org/rnoaa
Other
330 stars 84 forks source link

Unable to pull either monthly_normal or hourly_normal #256

Closed udayguntupalli closed 5 years ago

udayguntupalli commented 6 years ago
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 [3] 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] bindrcpp_0.2 rnoaa_0.7.0 httr_1.3.1 loaded via a namespace (and not attached): [1] Rcpp_0.12.14 pillar_1.0.1 compiler_3.4.3 plyr_1.8.4 bindr_0.1 [6] tools_3.4.3 digest_0.6.13 lubridate_1.7.1 jsonlite_1.5 tibble_1.4.1 [11] gtable_0.2.0 pkgconfig_2.0.1 rlang_0.1.6 cli_1.0.0 rstudioapi_0.7 [16] curl_3.1 gridExtra_2.3 dplyr_0.7.4 stringr_1.2.0 xml2_1.1.1 [21] rappdirs_0.3.1 tidyselect_0.2.3 grid_3.4.3 glue_1.2.0 R6_2.2.2 [26] XML_3.98-1.9 ggplot2_2.2.1 tidyr_0.7.2 purrr_0.2.4 hoardr_0.2.0 [31] magrittr_1.5 scales_0.5.0 assertthat_0.2.0 mime_0.5 colorspace_1.3-2 [36] utf8_1.1.2 stringi_1.1.6 lazyeval_0.2.1 munsell_0.4.3 crayon_1.3.4 ```
id <- c(1,2,3)
latitude <- c(32.12,32.32,32.33)
longitude <- c(-11.95,-90.08,-88.75)
LocDF <- data.frame(id,latitude,longitude)

# Identify the right GHCND Stations 
stationdata <-  ghcnd_stations()
Test <- rnoaa::meteo_nearby_stations(lat_lon_df = LocDF,station_data = stationdata,var = "all",radius = 50,
                                     limit = 1
                                    )
Test <- data.frame(t(sapply(Test,c)))
T <- rnoaa::ncdc(datasetid = "NORMAL_HLY",stationid = "US1MSRN0042",startdate = "2010-01-01",enddate = "2010-12-31")
T <- rnoaa::ncdc(datasetid = "NORMAL_MLY",stationid = "US1MSRN0042",startdate = "2010-01-01",enddate = "2010-12-01")

I tried to use the ncdc function to pull NORMAL_HLY and NORMAL_MLY data. In both cases - for more than one ghcnd station, I keep receiving a message of no data found. Wondering if I am using the function correctly ? Can you provide an example of pulling NORMAL_MLY data please for any GHCND station

sckott commented 6 years ago

thanks, will have a look

sckott commented 6 years ago

sorry for the very late response @udayguntupalli - this slipped through my fingers for some reason

meteo* functions work with FTP data retrieved through ghcnd() function - which means only Daily data

ncdc retrieves data from various datasets, including NORMAL_MLY

try this:

# you can search stations by extent (bounding box) with ncdc_stations()
ncdc_stations(datasetid = "NORMAL_MLY", extent=c(32, -90.4, 32.6, -89.7))

# then search with ncdc() using one of those stations
# make sure to use the whole station id including the prefix GHCND
ncdc(datasetid = "NORMAL_MLY",stationid = 'GHCND:USC00226811', startdate = "2010-04-01",enddate = "2010-04-30")