[R-sig-Geo] Trying to reproduce rLandsat8 package codes

Jackson Rodrigues j@ck@onmrodr|gue@ @end|ng |rom gm@||@com
Thu Aug 8 21:18:34 CEST 2019


Dear folks,

Could anyone give a support in downloading LandSat images ?

I am trying to reproduce codes from rLandSat8 package.
However I could not move to the next step due to a problem with the file
downloaded.

*#First step: Download a file for a reproducible example like suggested*
#####################
DownloadLandsat <- function(url, output.name) {
  # todo: use RCurl instead of the system call

command.args <- paste0("-c cookies.txt -d 'username=",
usgs.username="myusername", "&password=", usgs.password="mypassword","'
https://earthexplorer.usgs.gov/login")

  # invoke the system call to curl.
  # I'd rather have done this with RCurl but couldn't get it working ;-(
  ret <- system2("curl", command.args, stdout=TRUE, stderr=TRUE)

  command.args <- paste0("-b cookies.txt -L ", url," -o ", output.name)
  ret <- system2("curl", command.args, stdout=TRUE, stderr=TRUE)
  #file.remove(cookies.txt)
  return(ret)
}
setwd("my folder")
curl_download(DownloadLandsat("
http://earthexplorer.usgs.gov/download/4923/LC82040322013219LGN00/STANDARD/INVSVC",
"LC82040322013219LGN00"))

*#Second Step: Use the file downloaded to reproduce the code.  *
####################
setwd("my folder")
product  <- "LC82040322013219LGN00"
l <- ReadLandsat8(product)
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
  cannot open file 'LC82040322013219LGN00/LC82040322013219LGN00_MTL.txt':
No such file or directory

The file is in my folder and it seems to be downloaded properly.
However, this file has no extension in other words, it is
LC82040322013219LGN00 and not  LC82040322013219LGN00_MTL.txt.

What is wrong?
Is there any other easier way to download LandSat images using R? Long
series for example?

Best regards,

Jackson

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list