fdetsch / MODIS

Download and processing framework for MODIS imagery. The package provides automated access to the global online data archives LP DAAC, LAADS and NSIDC as well as processing capabilities such as file conversion, mosaicking, subsetting and time series.
Other
58 stars 27 forks source link

Help downloading MODIS data in R #114

Closed Avtober closed 2 years ago

Avtober commented 3 years ago

Hi, I am trying to download NDVI from MODIS and used the following code but am having issues:

devtools::install_github("MatMatt/MODIS", ref = "develop") library(MODIS)

MODIS = runGdal("MOD13Q1", collection = "006", tileH = 20, tileV = 11, begin = "2000.02.18", end = "2010.03.10", job = "MOD13Q1", SDSstring = "110000000000") # extract NDVI and EVI

I get the following error message: ######################## outProj = asIn pixelSize = asIn resamplingType = near Output directory = C:/Users/avtob/AppData/Local/Temp/RtmpKeYFk0/MODIS_ARC/PROCESSED/MOD13Q1.006_20210816171601 (no 'job' name specified, generated (date/time based)) ######################## Downloading structure on 'LPDAAC' for: MOD13Q1.006 Hm, I have to search for the file. Next time provide the full path and I'll be very fast! Error in strsplit(x, ":") : non-character argument

Please help, I am not sure what it means by provide the full path, how do I do this?

Thanks Anya

fdetsch commented 3 years ago

@Avtober Can you have a look at https://github.com/MatMatt/MODIS/issues/111#issuecomment-902473477 (similar issue) and try to provide the required information?

Avtober commented 3 years ago

Hi @fdetsch, If I run the traceback i get the following:

> traceback()
7: strsplit(x, ":")
6: getSdsNames(SDSnames)
5: gsub("\"", "", getSdsNames(SDSnames))
4: getSds(HdfName = y, SDSstring = SDSstring)
3: FUN(X[[i]], ...)
2: lapply(files, function(y) {
       getSds(HdfName = y, SDSstring = SDSstring)
   })
1: runGdal("MOD13Q1", collection = "006", tileH = 20, tileV = 11, 
       begin = "2000.02.18", end = "2010.03.10", job = "MOD13Q1", 
       SDSstring = "110000000000")

Not sure if that is helpful. Thanks Anya

fdetsch commented 3 years ago

I deleted everything that is not relevant at this stage from your answer – hope that's okay.

From your first post, it looks like you are attempting to download to a temporary folder, which I would not recommend for such big data. Can you do me a favor and set localArcPath to a permanent folder on your hard drive? Then verify if the downloaded .hdf file is several 100 MB large or if you're seeing empty files (i.e. something close to 0 kB) only. For example, do the following (remember to change lap that defines the local download folder):

library(MODIS)

## enable permanent file storage
lap = "~/Documents/data/MODIS_ARC"
MODISoptions(
  localArcPath = lap
  , outDirPath = file.path(
    lap
    , "PROCESSED"
  )
)

## download data for most recent collection
product = "MOD13Q1"

clc = getCollection(
  product
  , forceCheck = TRUE
)

tfs = runGdal(
  product
  , collection = clc
  , tileH = 20
  , tileV = 11
  , begin = "2000.02.18"
  , end = "2000.02.18"
  , job = "MOD13Q1"
  , SDSstring = "11" # ndvi, evi
)
Avtober commented 3 years ago

Hi @fdetsch,

Thanks, I tried that and it created the folder but the folder was empty. I have copied the outcome and the error message below:

Setting 'localArcPath' to 'C:/Users/avtob/OneDrive/Documents/Documents/data/MODIS_ARC' If you already have downloaded some HDF files, you can use '?orgStruc' to rearrange them. 'outDirPath' has been changed from 'C:/Users/avtob/AppData/Local/Temp/RtmpS2IFWF/MODIS_ARC/PROCESSED/' to 'C:/Users/avtob/OneDrive/Documents/Documents/data/MODIS_ARC/PROCESSED'. File '~/.MODIS_Opts.R' does not exist. Create it now to make settings permanent? [y/n]: n

STORAGE:


localArcPath : C:/Users/avtob/OneDrive/Documents/Documents/data/MODIS_ARC outDirPath : C:/Users/avtob/OneDrive/Documents/Documents/data/MODIS_ARC/PROCESSED

DOWNLOAD:


MODISserverOrder : LPDAAC, LAADS dlmethod : auto stubbornness : high wait : 0.5 quiet : TRUE

PROCESSING:


GDAL : 3.2.1 MRT : Enabled pixelSize : asIn outProj : asIn resamplingType : NN dataFormat : GTiff cellchunk : 1

product = "MOD13Q1" clc = getCollection(

  • product
  • , forceCheck = TRUE) tfs = runGdal(
  • product
  • , collection = clc
  • , tileH = 20
  • , tileV = 11
  • , begin = "2000.02.18"
  • , end = "2000.02.18"
  • , job = "MOD13Q1"
  • , SDSstring = "11" # ndvi, evi
  • ) ######################## outProj = asIn pixelSize = asIn resamplingType = near Output Directory = C:/Users/avtob/OneDrive/Documents/Documents/data/MODIS_ARC/PROCESSED/MOD13Q1 ######################## Downloading structure on 'LPDAAC' for: MOD13Q1.061 Hm, I have to search for the file. Next time provide the full path and I'll be very fast! Error in strsplit(x, ":") : non-character argument

Thanks Anya

fdetsch commented 3 years ago

Is a file ~/.netrc present and are the credentials therein correct? In RStudio, you can easily find out with file.edit("~/.netrc").

Avtober commented 3 years ago

It brings up the file but it looks like its empty.

fdetsch commented 3 years ago

One step closer, I guess. Please run EarthdataLogin() and enter your Earthdata credentials (see ?EarthdataLogin for details). Afterwards, try again the code from https://github.com/MatMatt/MODIS/issues/114#issuecomment-903875483.

Avtober commented 3 years ago

I think that worked, I now have a HDF file of around 200,00KB and two Tiff files (NDVI and EVI) in the processed folder! I guess I can try this with the larger data now?

Thanks for your help! Anya

fdetsch commented 3 years ago

Happy to help. Let me know if you encounter other problems. Closing this once the availability of Earthdata credentials can be verified through the package, see https://github.com/MatMatt/MODIS/pull/115.