ropensci / rnoaa

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

Question about retrieving NORMAL_DLY weather data #302

Closed minheeseo closed 5 years ago

minheeseo commented 5 years ago

Hi, I am trying to retrieve normal temperature data using rnoaa r package, and I have two questions.

  1. Following codes return empty lists. Does meteo_nearby_stations() function not work on normal temperature data? dat <- read.table(header = TRUE, sep = ",", text = " longitude, latitude, id 23.894614, 52.744313,712") normal_station <- meteo_nearby_stations(dat, lat_colname = "latitude", lon_colname = "longitude", station_data = ghcnd_stations(), var = "NORMAL_DLY", year_min = 2010, year_max = 2010, radius = 100, limit=30) previous_normal<- meteo_nearby_stations(dat, lat_colname = "latitude", lon_colname = "longitude", station_data = ghcnd_stations(), var = "NORMAL_DLY", year_min = 2000, year_max = 2000, radius = 100, limit=30)
  2. Also, there are two different types of normal temperature, 1981-2010 normal and 1971-2000 normal. Is it possible to differentiate this type using your package? Thank you!
sckott commented 5 years ago

thanks @minheeseo for this

just for reproducible code (it didnt' work for me, and to reduce multiple calls to ghcnd_search):

dat <- read.table(header = TRUE, sep = ",", 
    text = "longitude,latitude,id\n23.894614,52.744313,712")
xx <- ghcnd_stations()
normal_station <- meteo_nearby_stations(dat,
    lat_colname = "latitude", lon_colname = "longitude",
    station_data = xx, var = "NORMAL_DLY", year_min = 2010, 
    year_max = 2010, radius = 100, limit=30)
#> $`712`
#> # A tibble: 1 x 5
#>   id    name  latitude longitude distance
#>   <chr> <chr>    <dbl>     <dbl>    <dbl>
#> 1 NA    NA          NA        NA       NA

meteo_nearby_stations(dat,
    lat_colname = "latitude", lon_colname = "longitude", 
    station_data = xx, var = "NORMAL_DLY", year_min = 2000, 
    year_max = 2000, radius = 100, limit=30)
#> $`712`
#> # A tibble: 1 x 5
#>   id    name  latitude longitude distance
#>   <chr> <chr>    <dbl>     <dbl>    <dbl>
#> 1 NA    NA          NA        NA       NA

The meteo* functions are only for the dataset GHCND, see the datasets table in the readme https://github.com/ropensci/rnoaa#noaa-ncdc-datasets - and the var parameter you used is for parameters, or types of data, not types of datasets.

To get stations for NORMAL_DLY data, e.g., try

# note that data for NORMAL_DLY is only avail. for the year 2010
ncdc_datasets()$data 
# an eg request
# note that the parameters are different, extent instead of radius
ncdc_stations(datasetid = 'NORMAL_DLY', 
    startdate='20100101', enddate='20101231',
    extent = c(45.5204, -132.2047, 50.6139, -100.1065))
minheeseo commented 5 years ago

Right. I meant to ask about DLY-TAVG-NORMAL from NORMAL_DLY data. @sckott Thank you so much for the example, and I really appreciate your help!

sckott commented 5 years ago

does this solve your problem?

minheeseo commented 5 years ago

For the first question. For the second one, I was able to access 1971-2000 Daily Normal data via FTP (ftp://ftp.ngdc.noaa.gov/). Thanks!