Guest User

Untitled

a guest
Sep 5th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. getAOD <- function(user = 'EarthDataUsername' # enter your user name
  2. ,pw = 'EarthDataPassword' # enter your password
  3. ,dir = 'OutputDestinationFolder'# enter a path to directory
  4. ,product = 'MCD19A2' # default product for MAIAC AOD
  5. ,date = '2018.08.28' # day of interest
  6. ,tile = 'h09v04' # your tile id (depends on your location)
  7. ,collection = "006") {
  8.  
  9. # parse date and julian date for url building
  10. Date <- lubridate::ymd(date)
  11. julianDate <- paste0(lubridate::year(Date)
  12. ,lubridate::yday(Date))
  13.  
  14. # extracts hdf files for a given tile across all observation times
  15. pattern <- paste0(product, ".A", julianDate, ".", tile, ".", collection, "*.hdf")
  16.  
  17. # base url for wget
  18. url <- paste0("https://e4ftl01.cr.usgs.gov/MOTA/", product, ".", collection, "/", date, "/")
  19.  
  20. # call wget from command line
  21. system(paste0("wget -r -A", pattern, " -L --user=", user
  22. ," --password=", pw
  23. ," --directory-prefix=", dir
  24. ," --load-cookies ~/.cookies --save-cookies ~/.cookies ", url))
  25.  
  26. }
  27.  
  28. getAOD(user = 'myUserName'
  29. ,pw = scan("./batteries.dppss", what = "")
  30. ,dir = "./test")
Add Comment
Please, Sign In to add comment