For a normal GIS user, QGIS 3 brings a lot of new tools, new forms to perform spatial analysis but also it doesn´t bring (yet) some options available in QGIS 2. This is the case for the representation of HDF raster files that is not available in QGIS 3 but it is available in QGIS 2. Research have been performed to address this issue and many options were evaluated to open the HDF files and perform a geotransformation from Sinusoidal Coordinate System to Geographical Coordinate System.
The solution came from the powerful gdal library and some core Python functions. This tutorial show the procedure to open a layer of a MOD13A2, a MODIS data product for vegetation evaluation and reproject it to geographical coordinate system (lat/lon).
This is the Python code that open the HDF file, reproject one layer to WGS84 and bring it to canvas.
import gdal, os ## List input raster files os.chdir('C:\\Users\\USER\\Documents\\Infohataris\\HDFReproyectionPyQGIS\\inputRaster') rasterFiles = os.listdir(os.getcwd()) print(rasterFiles) ## Open HDF file hdflayer = gdal.Open(rasterFiles, gdal.GA_ReadOnly) # Open raster layer rlayer = gdal.Open(hdflayer.GetSubDatasets(), gdal.GA_ReadOnly) # Define output raster and warp-reproject outputName = rlayer.GetMetadata_Dict()['LOCALGRANULEID'][:-4]+'_NDVI.tiff' outputRaster = '..\\outputRaster\\'+ outputName gdal.Warp(outputRaster,rlayer,dstSRS='EPSG:4326') # Add output raster to canvas iface.addRasterLayer(outputRaster, outputName)
You can download the input files for this tutorial here.
Website of NADA Earthdata Search to download MOD13A2 files:
More information on the MOD13A2 vegetation data product: