Closed dhersz closed 2 years ago
Hi Daniel.
This problem can occur because of latency issue in our server where we store the data. When this problem occurs, geobr downloads and stores in memory a corrupted metadata
file, so next read_
calls cannot find the data in the metadata.
short term solution In this case, the short term solution is to simply restart the R session or clean the temporary files.
long term solution
The geobr package currently checks if there is internet connection on both sides (user and server), but I haven't found a way to test if there are latency issue. The long term solution here would be to (1) test connection latency, and (2) throw a message (and not an ERROR) where there is Connection timed out
My problem with this error is that it's not clear in what is the problem.
Perhaps when reading the metadata file you could use tryCatch()
to check for any errors (or more specifically, this error). In case of error you delete the metadata file and proceed with the usual process (download metadata file to later download the dataset). If the server is still unstable, you'll get the previous (and clearer) error message, regarding timeout.
oh well, I just got a message from CRAN saying that geobr
is not "falling gracefully" . This needs to be fixed before Jan 8th
related SO question with promising solution. https://stackoverflow.com/questions/12193779/how-to-write-trycatch-in-r
I have wrapped all httr::GET(..)
calls to download files with try( ..., silent = TRUE)
Probably related to the metadata file.