Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createMosaicGDAL AttributeError #161

Open
ajvershov-alt opened this issue Jan 4, 2024 · 6 comments
Open

createMosaicGDAL AttributeError #161

ajvershov-alt opened this issue Jan 4, 2024 · 6 comments

Comments

@ajvershov-alt
Copy link

ajvershov-alt commented Jan 4, 2024

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.

@lucadelu
Copy link
Owner

lucadelu commented Jan 4, 2024

@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?

@ajvershov-alt
Copy link
Author

@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
Copy link
Author

@lucadelu What should I do with the XML files?

@lucadelu
Copy link
Owner

lucadelu commented Jan 8, 2024

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

@ajvershov-alt
Copy link
Author

ajvershov-alt commented Jan 8, 2024

@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
Copy link
Author

ajvershov-alt commented Jan 8, 2024

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants