I need to convert an "Aura OMI NO2 Data Product" in .he5 format to a Tiff.
Using Python, I achieve the conversion with the following code:
trans = "gdal_translate -of GTiff -sds -a_srs WGS84 -a_ullr -180 90 180 -90" + " " + input_file + " " + output_file" os.system(trans)
I am trying to write this command within Python, but have not found how to override the georeferenced bounds as the GDAL command
-a_ullr ulx uly lrx lry does.
The code I have is the following:
# Import gdal and osr import gdal import osr # Open he5 file src_ds = gdal.Open(input_file) # Get the 4th subdataset and open it subdatasets = src_ds.GetSubDatasets() mysds = subdatasets sub_ds = gdal.Open(mysds) # Set Projection srs = osr.SpatialReference() srs.ImportFromEPSG(4326) sub_ds.SetProjection(srs.ExportToWkt()) # Convert to Tiff format = "GTiff" driver = gdal.GetDriverByName( format ) dst_ds = driver.CreateCopy( destination_tif, sub_ds, 0 ) # Clean up dst_ds = None src_ds = None sub_ds = None
I need to set the bounds of the generated raster, as it doesn't match up correctly. In the following picture, the top raster was generated with my imbedded Python code, whereas the bottom was created with the GDAL_translate.
Furthermore, is it better practise to assign the Projection and Bounds to the subdataset or to the Tiff once it has been generated?