pyModis icon indicating copy to clipboard operation
pyModis copied to clipboard

createMosaicGDAL AttributeError

Open ajvershov-alt opened this issue 1 year ago • 6 comments

Hello,

I've come across an issue whenever I try to use createMosaicGDAL.

The code I've written:

hdf_list = ['D:/MODIS/MCD18A1.A2020001.h10v03.061.2020350135843.hdf',
            'D:/MODIS/MCD18A1.A2020001.h11v03.061.2020350135958.hdf',
           ]

modis_mosaic = pymodis.convertmodis_gdal.createMosaicGDAL(
    hdfnames = hdf_list,
    subset = False,
    outformat = 'GTiff'
    )

modis_mosaic.run('D:/MODIS/mosaic_file')

The error I get:

Traceback (most recent call last):

File "C:\Users\user\PycharmProjects\pymodis_project\modis_download.py", line 54, in <module> 
modis_mosaic.run('mosaic_file')

File "C:\Users\user\miniconda3\envs\pymodis\lib\site-packages\pymodis\convertmodis_gdal.py", line 619, in run
self.write_mosaic_xml(output)

File "C:\Users\user\miniconda3\envs\pymodis\lib\site-packages\pymodis\convertmodis_gdal.py", line 591, in write_mosaic_xml
pmm.writexml("%s.xml" % prefix)

File "C:\Users\user\miniconda3\envs\pymodis\lib\site-packages\pymodis\parsemodis.py", line 982, in writexml 
self.valMeasuredParameter(mpc)

File "C:\Users\user\miniconda3\envs\pymodis\lib\site-packages\pymodis\parsemodis.py", line 821, in valMeasuredParameter 
for val in i.retMeasure().values():

File "C:\Users\user\miniconda3\envs\pymodis\lib\site-packages\pymodis\parsemodis.py", line 208, in retMeasure 
for i in meStat.iter():

AttributeError: 'NoneType' object has no attribute 'iter'

I assume the issue is with what I've written for "subset"? I'm trying to mosaic all of the data together, not just one or two bands. I've tried specifying subsets anyway, but it still doesn't work.

I'm using Python 3.8.18, pyModis 2.3.0, and GDAL 3.8.2.

ajvershov-alt avatar Jan 04 '24 17:01 ajvershov-alt

@kaminka-krasovsky to select all the band it is better to set a list of 1 as the number of the band. Do you have xml file for that two .hdf files?

lucadelu avatar Jan 04 '24 22:01 lucadelu

@lucadelu Yes, here are their filenames:

MCD18A1.A2020001.h10v03.061.2020350135843.hdf.xml MCD18A1.A2020001.h11v03.061.2020350135958.hdf.xml

How would I set a list of 1? Would I write it as just '1' or some other way?

ajvershov-alt avatar Jan 04 '24 23:01 ajvershov-alt

@lucadelu What should I do with the XML files?

ajvershov-alt avatar Jan 06 '24 20:01 ajvershov-alt

the XML files are used internally to read some parameters, @kaminka-krasovsky could you please share your data to test?

lucadelu avatar Jan 08 '24 06:01 lucadelu

@lucadelu I compressed the HDFs and XMLs into a ZIP, but I'm having trouble getting Git LFS to track them in a repository so that I may share them.

I can, however, show how I downloaded the data through pyModis:

modis_down = pymodis.downmodis.downModis(
    destinationFolder = 'D:/MODIS',
    password = 'password',
    user = 'user',
    url = 'https://e4ftl01.cr.usgs.gov',
    path = 'MOTA',
    tiles = ['h11v03', 'h10v03'],
    today = '2020-01-01',
    delta = 1,
    product = 'MCD18A1.061',
    debug = True
    )

modis_down.connect()

modis_down.downloadsAllDay()

ajvershov-alt avatar Jan 08 '24 18:01 ajvershov-alt

@lucadelu Update: I successfully got Git LFS to track the ZIP in the repository. I've added you to the repository as a collaborator.

Thank you for looking into this.

ajvershov-alt avatar Jan 08 '24 18:01 ajvershov-alt