I've have MODIS ndvi data (MODIS_Grid_16 days NDVI) from the iberian peninsula, from February of 2000 to August of 2012 (really big data).

How do I batch convert about 800 .hdf MODIS files to .tif ?

I can use QGIS/GRASS/SAGA/GDAL/R but I have no experience with bash scripts.

  • I think you will get better answers if you refine your post to include 1 question rather than 4.
    – Aaron
    Commented Mar 20, 2014 at 15:44

3 Answers 3


If you know R, you can use the package "gdalUtils" and run gdal_translate to do that. If you are on Linux make sure to install GDAL. If you are on Windows, you're good to go.

These are the basic commands to handle the conversion to .tiff and the reprojection to WGS84.

out.files <- list.files(getwd(), pattern="hdf$", full.names=FALSE) #create a list with names of the .hdf files (they should be stored in your workspace)

gdal_translate("Your_Image.hdf","Your_Image_Out.tif",sd_index=1) #extracts the NDVI band (sd_index=1) and converts to .tiff

gdalwarp("Your_Image_Out.tif","Your_Image_OutWGS84.tif",s_srs="+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs",t_srs="+proj=longlat +datum=WGS84 +no_defs",srcnodata=-3000,dstnodata=-3000) #handles the conversion to WGS84

If all these commands work for you, wrap them up in a loop and you're good to go.


Using a loop in bash, it might be:

for h in *.hdf; do \
t=`basename $h .hdf`.tif; 
gdal_translate $h $t;

If you have to do this once, I would also recommend using gdal_translate like in the above answer given by Filipe Dias. However, if you are working a lot with MODIS data, you should probably also have a look at Matteo Mattiuzzi's MODIS package (see modis: R Development Page). It is easy to use and offers a lot of opportunities to download and process MODIS-based satellite data from both Aqua and Terra. A quite useful introduction has been published on Steven Mosher's Blog a while ago. Note that you'll need a valid GDAL version and the MODIS Reprojection Tool (MRT) installed on your local system.

You might possibly want to have a look at options("MODIS_localArcPath") and options("MODIS_outDirPath") and adjust the referring arguments in MODISoptions() before starting the actual data processing. Without going too much into detail (see both ?MODISoptions and ?runGdal for further information), it basically all comes down to some single lines of code, which would in your case approximately look as follows focussing on the Terra satellite only:

# Install and load package
install.packages("MODIS", repos="http://R-Forge.R-project.org")

# Loop through vertical MODIS tiles covering the Iberian Peninsula
for (tileV in c(4, 5)) {
  runGdal(product = "MOD13Q1", 
          tileH = 17, tileV = tileV, 
          start = "2000-02-01", end = "2012-08-31", 
          outProj = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")

If you have already downloaded the data and want to try the MODIS package anyway, you should also have a look at ?orgStruc to organise your data in an adequate storage structure that can be handled by the package prior to executing runGdal. Those tiles that are already available on your local drive won't be downloaded from LP DAAC then, and the resulting GeoTiff images will be stored in options("MODIS_outDirPath").

Once more, please note that this answer is only intended as a thought-provoking impulse. gdal_translate is probably much less time-consuming and you should definitely consider the referring answer above to guarantee a fast and easy processing of your data.


  • Thanks for the orgStruc tip, I'll look at it. Yes, in fact gdal_translate it's pretty easy to handle with.
    – JMarcelino
    Commented Mar 25, 2014 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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