hunter-stanke / rFIA

rFIA
https://rfia.netlify.com/
47 stars 23 forks source link

Error when downloading tables for several states #49

Open flakesw opened 12 months ago

flakesw commented 12 months ago

Hi there,

I recently updated to the dev version so that I could download some new tables with the change to the URLs on the datamart, but I now get this error if I try to download data for more than one state. Here's an example:

> getFIA(states =  c("RI", "CT"),
+        dir = 'D:/Data/fia/rFIA_downloads/',
+        common = TRUE,
+        load = FALSE)
Saving to D:/Data/fia/rFIA_downloads/. NOTE: modifying FIA tables in Excel may corrupt csv files.
Error in if (states == "REF") { : the condition has length > 1

I think the error happens in line 441 here: https://github.com/hunter-stanke/rFIA/commit/b80e18092dc9ef6783d6b4e37678cc13d71b8baf

I think it could be fixed if you were to check if the length of states was >1, and then check if any of those states are "REF", and throw an error in that case.

It also looks like the "ENTIRE" option is broken, perhaps due to the datamart update. I get this error if I try it:

trying URL 'https://apps.fs.usda.gov/fia/datamart/CSV/ENTIRE_CSV.zip' Error in download.file(url, temp, timeout = 3600) : cannot open URL 'https://apps.fs.usda.gov/fia/datamart/CSV/ENTIRE_CSV.zip' In addition: Warning messages: 1: In download.file(url, temp, timeout = 3600) : downloaded length 0 != reported length 1245 2: In download.file(url, temp, timeout = 3600) : cannot open URL 'https://apps.fs.usda.gov/fia/datamart/CSV/ENTIRE_CSV.zip': HTTP status was '404 Not Found'

Thanks for putting together such a useful package! Let me know if I can help troubleshoot.

flakesw commented 12 months ago

It looks like Jacob Fraser already solved it in this PR: https://github.com/hunter-stanke/rFIA/pull/46 Jacob's fork is working fine for me.

mikoontz-vp commented 7 months ago

Flagging here that @jacobf37's fork also worked for me, but I had the same issue that @flakesw pointed out

jacobf37 commented 7 months ago

I added an argument to the getFIA function to set a value for the timeout option with a default of 3600.