[GIS] Not able to bulk download MODIS images

downloadmodisr

I am trying to download Modis NDVI and EVI images. I have used the following R-code:

    setwd("/home/karthik/Valmiki/Modis_bands/")
    library(raster)
    library(RCurl)
    source("ModisDownload.R") ##ModisDownload.R is in the setwd directory#
    X="MOD13Q1"
    getMODIS(x=X, h=25, v=6, dates = c('2000.02.18', '2014.07.31'),  version='005')

I am getting the following error:

    Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
    In addition: Warning message:
    In readChar(con, 5L, useBytes = TRUE) :
    cannot open compressed file 'ModisLP.RData', probable reason 'No such file or directory'

I am using Ubuntu 12.04. Please let me know me where I am going wrong.

Best Answer

Here is a quick workaround using the MODIS package:

# install.packages("MODIS")
library(MODIS)

MODISoptions(localArcPath = "/path/to/modis/files", 
             outDirPath = "/path/to/modis/files/processed")

runGdal("MOD13Q1", collection = "006", # see getCollection("MOD13Q1", forceCheck = TRUE)
        tileH = 25, tileV = 6, # MODIS tile id
        begin = "2000.02.18", end = "2000.03.31", # time period
        SDSstring = "110000000000") # SDS layers to extract (here: NDVI, EVI)

If you don't want to extract certain SDS layers, but deal with the raw .hdf files instead, simply use getHdf instead of runGdal and drop 'SDSstring'.