使用时出错pymodis.convertmodis.createMosai

2024-06-28 20:14:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用pymodis来重新投影和拼接数据集,使用MRT。我使用pymodis包成功地重新投影了数据,如下所示:

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()

这工作得很好,但当我使用创建马赛克时,我遇到了问题。请告诉我我哪里出错了。在

^{pr2}$

在马赛克输入.txt包含以下文件:

MOD15A2.A2001025.h27v08.005.2006356072429.hdf MOD15A2.A2001025.h27v09.005.2006356181328.hdf MOD15A2.A2001025.h28v08.005.2006356073508.hdf MOD15A2.A2001025.h28v09.005.2006356075256.hdf

运行此代码时,出现以下错误:


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

此模块的语法如下:

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’ 

Tags: theinpyliblinemodislistfile
1条回答
网友
1楼 · 发布于 2024-06-28 20:14:08

所以我一直在试着运行modis_马赛克.py我相信python脚本可以完成您在这里尝试的相同工作。我也犯了同样的错误布拉布拉赫.hdf文件不存在”。以下是我找到的补救方法:

因此,脚本被赋予了文本文件的路径,但它没有意识到.hdf文件将在该目录中搜索,而是搜索pymodis/scripts目录中的文件。我之所以这么说,是因为在我将.hdf文件复制到pymodis/scripts文件夹,然后尝试执行该命令后,它工作得非常好。\

我认为这是因为python的特性,它总是搜索当前目录中的文件,除非像我们指定的.txt文件那样明确指定

希望有道理

相关问题 更多 >