Reputation: 649
I am using pymodis to reproject and mosaic the datasets using MRT. I have successfully reprojected the data using pymodis package as below :
list_modis=glob.glob('*.hdf')
for i in range(0,len(list_modis)):
name=parameter_file(INPUT_folder,list_modis[i],left_x,right_x,top_y,bottom_y)
x=pymodis.convertmodis.convertModis(list_modis[i],'param.prm','C:\\MRT\\')
x.run()
This works perfectly well, but when I am using Create Mosaic I got problem. Please suggest me where I have made mistake.
y=pymodis.convertmodis.createMosaic('mosaicinput.txt','mosaic','C:\\MRT\\')
y.run()
Mosaicinput.txt has following files:
MOD15A2.A2001025.h27v08.005.2006356072429.hdf MOD15A2.A2001025.h27v09.005.2006356181328.hdf MOD15A2.A2001025.h28v08.005.2006356073508.hdf MOD15A2.A2001025.h28v09.005.2006356075256.hdf
When I run this code, I got the following error :
Traceback (most recent call last): File "C:\Users\Jaya_HOME\Desktop\WEB DHM Toolbox\script\modis_mosaic.py", line 125, in y.run() File "C:\Python27\ArcGIS10.1\lib\site-packages\pymodis\convertmodis.py", line 177, in run self.write_mosaic_xml() File "C:\Python27\ArcGIS10.1\lib\site-packages\pymodis\convertmodis.py", line 156, in write_mosaic_xml pmm = parseModisMulti(listHDF) File "C:\Python27\ArcGIS10.1\lib\site-packages\pymodis\parsemodis.py", line 555, in __init__ self.parModis.append(parseModis(i)) File "C:\Python27\ArcGIS10.1\lib\site-packages\pymodis\parsemodis.py", line 64, in __init__ raise IOError('{name} does not exist'.format(name=filename)) IOError: MOD15A2.A2001025.h27v08.005.2006356072429.hdf MOD15A2.A2001025.h27v09.005.2006356181328.hdf MOD15A2.A2001025.h28v08.005.2006356073508.hdf MOD15A2.A2001025.h28v09.005.2006356075256.hdf does not exist
This is the syntax of this module :
class pymodis.convertmodis.createMosaic(listfile, outprefix, mrtpath, subset=False)[source] A class to convert several MODIS tiles into a mosaic Parameters: listfile (str) – the path to file with the list of HDF MODIS file outprefix (str) – the prefix for output files mrtpath (str) – the full path to mrt directory which contains the bin and data directories subset (str) – a string composed by 1 and 0 according with the layer to mosaic. The string should something like ‘1 0 1 0 0 0 0’
Upvotes: 0
Views: 450
Reputation: 15
So I have been trying to run the modis_mosaic.py python script that I believe does the same job you are trying here. I got the same error that "blahblah.hdf file doesnot exist". Here is the remedy that I found :
So the script has been given a path to the text file but it doesn't realize that the .hdf files are to be searched in that directory itself and instead it searches for the files in the pymodis/scripts directory. I can say so because after I copied the .hdf files into the pymodis/scripts folder and then tried executing the command it worked perfectly.\
I think this is because of the nature of python, where it searches for the files always in it's current directory unless otherwise explicitly specified like we specified the .txt file
Hope it makes sense
Upvotes: 1