I have a list of HDF files from MODIS product (see in attached). I want import them in python using GDAL library. Show my steps and explanation in the code below :
1. Import required libraries :
from osgeo import gdal
import glob
2. Define the link to the folders :
inDir="...inputs/modis/MOD13A2v061/"
outDir="...outputs/modis/MOD13A2v061/""
mask = "..../extent.shp"
3. Import a list files with glob
files_hdf = glob.glob(inDir + '*.hdf')
4. After I want use a for loop to display HDF files and extract only
"NDVI" variable # (index=0) using "gdal.open" function and after
I want export all the files in geotiff #format (and clipped them with
mask) using 'gdal.Warp' function ==> But a the end I have # error !!!
(see below my code step)
kwargs = {'format': 'GTiff'}
for data_path in files_hdf:
dataset = gdal.Open(data_path, gdal.GA_ReadOnly)
subdataset = gdal.Open(dataset.GetSubDatasets()[0][0], gdal.GA_ReadOnly)
ds = gdal.Warp(destNameOrDestDS=outDir,srcDSOrSrcDSTab=subdataset, cutlineDSName=mask, *kwargs)
At the end I have this error :
TypeError: Warp() got multiple values for argument 'destNameOrDestDS'
I think the problem provided when exported the files with gdal.Warp, can you help me to improve the script?
Many thanks!
