You can download MODIS files directly from NASA Earthdata. Since I want to manage everything from downloading to analyzing MODIS data in Python, I’ll use PyModis for the download process:
.
Installing Required Libraries
I will use an Anaconda virtual environment to install libraries.
conda install -c conda-forge pymodis
conda install -c conda-forge libgdal
When installing PyModis with conda, GDAL is automatically installed as a dependency. However, if it is not installed for any reason, please install GDAL manually. Additionally, installing only PyModis may not enable HDF4 file support, and you may encounter an error such as:
warnings.warn("GDAL installation has no support for HDF4, please update GDAL", ImportError)
To resolve this issue, I installed libgdal to enable HDF4 support.
I’m using downmodis from PyModis to download MODIS files.
When you access the default URL, files, they are stored in
https://e4ftl01.cr.usgs.gov/MOLA/MYD11A2.061
MOLA/
├── MYD09A1.061/
│ ├── 2002.07.04/
│ ├── 2002.07.12/
│ └── ...
├── ...
├── MYD11A2.061/
│ ├── 2002.07.04/
│ ├── 2002.07.12/
│ └── ...
└── ...
To download those files by PyModis, you need to specify the location in the arguments: path and product.
In this case,
path: MOLA
product: MYD11A2.061
(where .061 is the version number)
The following code will download MYD11A2.061 files of h29v06 tile between 2024-01-01 and 2024-10-15.
from pymodis import downmodis
destination_folder = "downloads"
tiles = "h29v06"
path = "MOLA"
product= "MYD11A2.061"
today= "2024-01-01"
enddate= " 2024-10-15"
modis_downloader = downmodis.downModis(
destinationFolder=destination_folder,
password="your password",
user="your username",
tiles=tiles,
path=path,
product=prod,
today=today,
enddate=enddate,
)
modis_downloader.connect()
modis_downloader.downloadsAllDay()
SOCIAL SHARE CARD GENERATOR