Closed zxy1219 closed 8 years ago
Yes, please do share example code
Thanks! Here is
library(rnoaa)
library(rio)
index <- import("C:xxxxxxxxx/US_2011__site.xlsx")
head(index)
USAF=index$USAF
wban=index$WBAN
for ( i in 1:100)
{
if (1000<=wban[i] & wban[i]<10000) {
wban_mod=paste("0",wban[i],sep="")
} else if (100<=wban[i] & wban[i]<1000) {
wban_mod=paste("00",wban[i],sep="")
} else {
wban_mod=paste("",wban[i],sep="")
}
USAF_mod=paste("",USAF[i],sep="")
res <- isd(usaf=USAF_mod, wban=wban_mod, year=2011, path = "C:xxxxxxxxx/ISD_2011", overwrite = TRUE)
import.name <- paste(USAF_mod,"-",wban_mod,"-2011",sep='')
export.name <- paste(USAF_mod,"_",wban_mod,"_2011",sep='')
import.file <- paste('C:xxxxxxxxx/ISD_2011/',import.name,'.rds',sep='')
export.file <- paste('C:xxxxxxxxx/ISD_2011_csv/',export.name,'.csv',sep='')
data <- import(import.file)
vars <- c("usaf_station","wban_station","date","time","latitude","longitude","elevation","wind_direction","wind_speed","ceiling_height","visibility_distance","temperature","temperature_dewpoint","air_pressure")
data2 <- data[vars]
export(data2,export.file)
}
When I run the function res<- isd(usaf="722580", wban="13960", year=2011, path = "C:xxxxxxxxx/ISD_2011", overwrite = TRUE)
The error still happen. So I have to go to the NOAA website, and download those sites manually.
thanks, ill have a look, hope you don't mind but I formatted your code a bit so it's easier to read
@zxy1219 hmm, i need at least some of that file US_2011__site.xlsx
, or at least some of the usaf and wban pairs
Sorry for replying so late. Sure, here is the list: USAF WBAN 722640 93035 722535 12909 722536 12911 722700 23044 722436 12906 722550 12912 722505 12904 723510 13966 722560 13959 722533 12962 722595 13911 722615 22001 723630 23047 690190 13910 722670 23042 722580 13960 722510 12924 722517 12932 722555 12935 722656 23040 722660 13962 722530 12921 722500 12919 722650 23023 722630 23034 722597 93985 999999 12946
About a half of them can't be download due to the error. Thanks! Happy Easter!
thanks
all of those wban and usaf id pairs worked for me with the newest version, try again after reinstalling, like devtools::install_github("ropensci/rnoaa")
also, the output of a call to isd()
is a data.frame of the results, so there's no reason to read in the data again after calling that fxn as you'll have it already
Thanks! It works!
great
Thank you for helping me for the previous issue. Now I meet a new problem: when I'm downloading the ISD by sites using R, there is a error message come out very often: