hunter-stanke / rFIA

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

readFIA issues #27

Closed piceaSILC closed 2 years ago

piceaSILC commented 2 years ago

I am just getting back to rFIA so by no means an expert. in my R code: db <- getFIA(states = 'ME') writeFIA(db, dir = "./FIAData")

Getting saved FIA data

db <- readFIA(dir = "./FIAData/")

I have tried several versions of my readFIA call with no success, this is error message.....

Error in fread(paste(dir, files[n], sep = ""), showProgress = FALSE, integer64 = "double", : File './FIAData/NA' does not exist or is non-readable. getwd()=='C:/Users/iprior/OneDrive - Seven Islands Land Co/3-Analytics/R/R_Scripts/rFIA'

It has written the data to the specified location, for whatever reason it will not load this saved data, any ideas?

I have tried this on local drives with the same result, a different error message...

writeFIA(db, dir = "C:/temp") Saving to C:/temp/. NOTE: modifying FIA tables in Excel may corrupt csv files.

dbLoad <- readFIA("C:/temp") Error in fread(paste(dir, files[n], sep = ""), showProgress = FALSE, integer64 = "double", : File 'c:/temp/NA' does not exist or is non-readable. getwd()=='C:/Users/iprior/OneDrive - Seven Islands Land Co/3-Analytics/R/R_Scripts/rFIA'

I have read/write permissions on these folders. Any ideas?

Thanks!

dsmaynard commented 2 years ago

You might need to include the "states" argument in the readFIA command, so:

db <- readFIA(dir = "./FIAData/", states = 'ME')

hunter-stanke commented 2 years ago

I apologize for the (severely) delayed response! I've started a new job in the last few months, and have been limited on time.

@dsmaynard is correct here. I would recommend explicitly defining the states that you would like to read in the call to readFIA, using the states argument. I would also recommend specifying byState=TRUE in the call to writeFIA, whenever you save changes to an FIA.Database. This will ensure that the csv's are split up by state when saved, thereby allowing you to use the states argument in subsequent calls to readFIA.

Please let me know if this doesn't take care of the issues - happy to dig deeper if needed. Thanks again!