datazoompuc / datazoom.amazonia

Simplify access to data from the Brazilian Amazon
Other
53 stars 7 forks source link

Error assuming windows path? #118

Closed MatthieuStigler closed 2 years ago

MatthieuStigler commented 2 years ago

Hi

I believe the package is assuming windows path (i..e using \ separators)? This would be a problem with Linux/Mac users.

Indeed, running load_deter(dataset = 'deter_amz', raw_data = TRUE) , I get error message (note the mixed separators):

Error: Cannot open "/tmp/RtmpOQISI6\deter_public.shp"; The file doesn't seem to exist.

But the file definitely exists: file.exists("/tmp/RtmpOQISI6/deter_public.shp") returns TRUE.

Looking at the code, I think you might just want to replace paste(dir, "deter_public.shp", sep = "\\") in _externaldownload with file.path() ,which makes sure to use / or \ depending on Windows versus Linux/Mac.

Thanks!

MatthieuStigler commented 2 years ago

I can still see a bunch of sep = "\\" in download.R, such as dat <- sf::read_sf(paste(dir, "Degrad2007_Final_pol.shp", sep = "\\"))?

This will certainly fail too:

data <- load_degrad(
     dataset = "degrad",
     raw_data = FALSE,
     time_period = 2013,
     language = "pt"
   )
trying URL 'http://www.obt.inpe.br/OBT/assuntos/programas/amazonia/degrad/arquivos/degrad2013_final_shp.zip'
Content type 'application/zip' length 4819285 bytes (4.6 MB)
==================================================
downloaded 4.6 MB

Error: Cannot open "/tmp/RtmpnP6Smh\DEGRAD_2013_INPE_pol.shp"; The file doesn't seem to exist.