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.
Answer
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.
No comments:
Post a Comment