The Jeffs have been exploring the UWisc AVHRR data which is stored as a lot of gzipped ncdf files. I couldn’t figure out how to download and open this data into R. So, as I usually do in these cases, I asked CA reader Nicholas who, as usual, has a solution. I edited this slightly to make a function which downloads and unzips the file into a temporary file which can be opened in ncdf and treated in usual ways. The call url can be structured to scrape data.
download.file(url, tempname, mode=”wb”)
# decompress the gzipped data into RAM
gz < – gzfile(tempname, "rb")
data <- readBin(gz, "raw", 104857600)
# write the decompressed data back to the temporary file
tempfile <- file(tempname, "wb")
#this creates a structured url; structures vary
nc < – open.ncdf(tempname)
Then you have to parse the netcdf object to try to find things, but this is standard parsing.