environmentalinformatics-marburg/GSODTools

USAF station code with leading zeros

Closed this issue · 3 comments

Hi

thank you for the great package!

There might be a small bug. The USAF code in dlGsodStations is numeric, but some stations starts with 0, ftp://ftp.ncdc.noaa.gov/pub/data/gsod/2016/ and so cannot be downloaded.

dlGsodStations(usaf=7026, start_year=2014, end_year=2015)
Processing GSOD station 7026 (WXPOD 7026) ... 
trying URL 'ftp://ftp.ncdc.noaa.gov/pub/data/gsod/2014/7026-99999-2014.op.gz'

instead of ftp://ftp.ncdc.noaa.gov/pub/data/gsod/2014/007026-99999-2014.op.gz

Thx
Christof

the following littel changes in dlGsodStations and gzGsodStations might correct this ;)

dlbase <- paste0(sprintf("%06d", dl_usaf$USAF), "-", dl_usaf$WBAN, "-",  year, ".op.gz")

fls <- list.files(dsn, pattern = paste(sprintf("%06d", usaf), ".gz$", sep = ".*"), full.names = TRUE)

I'll have a look into it soon. Thanks for reporting the issue!

Better late than never..

Commits dbab00e and 52e2296 should fix this. During utils::read.fwf(), columns STN---, WBAN, YEARMODA and FRSHTT are now assumed to be character, which means that leading zeros are preserved.