geanders / noaastormevents

explore noaa storm database
15 stars 1 forks source link

Fix for RCurl/SSL error #33

Open blairlo opened 3 years ago

blairlo commented 3 years ago

Hi, thanks for developing this package!

I was having the same problem as issue #31. It appears that the (now defunct?) RCurl call in your find_file_name function was throwing an ssl error in the dependent find_events function. Replacing with the curl/readlines seems to fix the problem. Below is the code I've substituted for the original. Feel free to use the appended function :

require(curl)

find_file_name2 <- function (year = NULL, file_type = "details") { url <- paste0("https://www1.ncdc.noaa.gov/pub/data/swdi/", "stormevents/csvfiles/") page<-readLines(curl(url)) #replace RCurl call with curl all_file_names <- XML::getHTMLLinks(page) file_year <- paste0("d", year, "") file_name <- grep(file_type, grep(file_year, all_file_names, value = TRUE), value = TRUE) if (length(file_name) == 0) { stop("No file found for that year and / or file type.") } return(file_name) }

assignInNamespace("find_file_name", find_file_name2, ns="noaastormevents")