pyModis
pyModis copied to clipboard
modis_convert creates many layers
Is there a way to create tiff's with multiple layers stemming from modis_convert.py? modis_mosaic allows you to mosaic multiple tiles into one tiff that has layers based on the bands of interest (ie modis_mosaic.py -s 1 1 1
will give you a 3-band raster with NDVI, EVI, and VIQ). However, using the same subset setup with modis_convert.py for a single frame creates 3 single-band rasters, with naming conventions indicating the layer they represent.
Right now no, it could be implemented. I will look on the code in the next days/week
I used library to create mosaic with multipe bands and convert the mosaic to tiff, but i got a tiff with only one band. So i want to know how to fix it, thank you.
#creat mosaic
from pymodis.convertmodis_gdal import createMosaicGDAL
inpath='E:\\202007\\data_analysis\\R\\test\\MODIS\\MYD09A1.006\\2002.07.04
outpath='E:\\202007\\data_analysis\\test'
files = glob.glob(os.path.join(inpath, 'MYD09A1.A2002*.hdf'))
subset=None
output_pref = os.path.join(outpath, 'MYD09A1.A2002185.mosaic')
mosaic = createMosaicGDAL(files, subset, 'GTiff')
mosaic.write_vrt(output_pref,separate=False)
#convert modis
from pymodis.convertmodis_gdal import convertModisGDAL
vrtfiles = glob.glob(os.path.join(outpath, 'MYD09A1.A2002*.vrt'))
for f in vrtfiles:
base = os.path.basename(f).replace('.vrt', '_vrt')
output = os.path.join(outpath, base)
convertsingle = convertModisGDAL(hdfname=f, prefix=output,
subset='None',
res=0,
resampl='NEAREST_NEIGHBOR',
epsg=4326, vrt=True)
convertsingle.run()