3

I am trying to analyze the MODIS EVI 250m, 16day dataset. I found the R MODIS package and am following the instructions here: https://conservationecology.wordpress.com/2014/08/11/bulk-downloading-and-analysing-modis-data-in-r/

But when I try to run the runGDAL function it tells me that:

library(MODIS)
dates1 <- as.POSIXct( as.Date(c("01/01/2015","31/12/2015"),format = "%d/%m/%Y") )
dates2 <- transDate(dates1[1],dates1[2])
product <- "MOD13Q1"
h = "25"
v = "07"
runGdal(product=product,begin=dates2$beginDOY,end = dates2$endDOY,tileH = h,tileV = v,SDSstring = "111", outProj="4326")

However I get the error:

Error in runGdal(product = product, begin = dates2$beginDOY, end = dates2$endDOY, : GDAL not installed or configured, read in '?MODISoptions' for help

I tried using the checkTools() command to set GDAL:

MODIS:::checkTools("GDAL")
Checking availabillity of GDAL: OK, GDAL 1.11.3, released 2015/09/16 found!

Does anybody have any ideas on how to fix this issue?

I'm using MODIS version 0.10.33. Output of MODISoptions():

STORAGE:
_______________
localArcPath : /Users/sujoybhattacharyya/MODIS_download
outDirPath   : /Users/sujoybhattacharyya/MODIS_download/Processed 
DOWNLOAD:
_______________
MODISserverOrder : LPDAAC, LAADS 
dlmethod         : auto 
stubbornness     : high 

PROCESSING:
_______________
GDAL           : Not available. Use 'MODIS:::checkTools('GDAL')' for more  information! 
MRT            : Not available. Use 'MODIS:::checkTools('MRT')' for more information! 
pixelSize      : asIn 
outProj        : asIn 
resamplingType : NN 
dataFormat     : GTiff 

DEPENDENCIES:
_______________
  • @SujoyBhattacharyya This is a long shot, but can you try re-installing the GDAL library in your system and/or install rgdal in your R library? It's not listed as a required package, but you never know... – Phil Mar 8 '16 at 16:26
  • @Phil , thanks for the suggestion. I tried it and alas nothing changed. – Sujoy Bhattacharyya Mar 13 '16 at 7:04
  • Thank you Aldo_Tapia for this, this helped me fix my problem when I was having trouble getting GDAL to work! I actually first had to properly install GDAL, but once I had GDAL properly installed this thread helped me get R to recognize and use GDAL. – marissa james May 4 '17 at 17:47
  • This is a comment, not an answer, so I flagged this. Please read the forum guidelines. – Jeffrey Evans May 4 '17 at 17:50
  • Please don't add "thank you" as an answer. Once you have sufficient reputation, you will be able to vote up questions and answers that you found helpful. - From Review – MaryBeth May 4 '17 at 18:16
1

You need to set the parameters of MRT and GDAL by yourself. I don't know exactly why R can't identify GDAL and MRT by default (I'm running R 3.3.1 in OS X 10.12), but I'll show you how I solve this error in my machine.

I have the same issue, this is the result of printing MODIS::MODISoptions():

To install all required and suggested packages run:
setRepositories() # activate CRAN, R-forge, and Omegahat and then: 
install.packages(c(' ptw '),dependencies=TRUE)

sh: gdalinfo: command not found
  'MRT_HOME' not set/found! MRT is NOT enabled! See: 'https://lpdaac.usgs.gov/tools/modis_reprojection_tool'

STORAGE:
_______________
localArcPath : /Users/aldotapia/Desktop/MODIS/Insumos 
outDirPath   : /Users/aldotapia/Desktop/MODIS/Resultados 


DOWNLOAD:
_______________
MODISserverOrder : LPDAAC, LAADS 
dlmethod         : auto 
stubbornness     : high 


PROCESSING:
_______________
GDAL           : Not available. Use 'MODIS:::checkTools('GDAL')' for more information! 
MRT            : Not available. Use 'MODIS:::checkTools('MRT')' for more information! 
pixelSize      : asIn 
outProj        : asIn 
resamplingType : NN 
dataFormat     : GTiff 


DEPENDENCIES:
_______________


Warning message:
In checkGdalDriver(path = opt$gdalPath) :
  No gdal installation found please install 'gdal' on your system first!

Check the paths of .Renviron:

> Sys.getenv("PATH")
[1] "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Library/TeX/texbin"

You need to add the GDAL path in this string, simply add : + gdal_path. Also, set MRT_HOME and MRT_DATA_BIN paths to .Renviron.

Sys.setenv(MRT_DATA_DIR  = "/Users/aldotapia/Desktop/MODIS/data",
           MRT_HOME = "/Users/aldotapia/Desktop/MODIS/bin",
           PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Library/TeX/texbin:/Library/Frameworks/GDAL.framework/Versions/2.1/Programs")

Now, check again MODIS::MODISoptions():

STORAGE:
_______________
localArcPath : /Users/aldotapia/Desktop/MODIS/Insumos 
outDirPath   : /Users/aldotapia/Desktop/MODIS/Resultados 


DOWNLOAD:
_______________
MODISserverOrder : LPDAAC, LAADS 
dlmethod         : auto 
stubbornness     : high 


PROCESSING:
_______________
GDAL           : GDAL 2.1.1, released 2016/07/07 
MRT            : Enabled 
pixelSize      : asIn 
outProj        : asIn 
resamplingType : NN 
dataFormat     : GTiff 


DEPENDENCIES:
_______________

Hope this can help you

  • I have been trying your solution for a while, but I haven't had any success. Any suggestions? – Vijay Ramesh Apr 24 '17 at 20:41
  • Can you use GDAL and MRT out of R? Maybe they aren't installed correctly – aldo_tapia Apr 24 '17 at 20:43
  • Can you elaborate? I currently have rgdal installed and when I use Sys.getenv - I get a long list of paths for different libraries. – Vijay Ramesh Apr 24 '17 at 20:46
  • I can post a different question if that helps? Let me know. – Vijay Ramesh Apr 24 '17 at 20:46
  • Use Sys.getenv("PATH"), check if GDAL path is in that string – aldo_tapia Apr 24 '17 at 20:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.