the below is my code, and the output says translation complete, but for some reason, the output file is not appearing the output directory. its not getting saved. please someone help me out.
`from osgeo import gdal
# Define file paths and dataset
file_path = r'D:MOPITT2000AprMOP03J-20000401-L3V5.9.3.he5'
dataset_path = 'HDFEOS/GRIDS/MOP03/Data_Fields/APrioriCOMixingRatioProfileDay'
output_path = r'D:MOPITT2000Aprgdaloutput.tif'
# Construct full path
full_path = f'HDF5:"{file_path}"://{dataset_path}'
# Open the dataset
dataset = gdal.Open(full_path)
if dataset:
print("Dataset opened successfully.")
print("Raster Size:", dataset.RasterXSize, "x", dataset.RasterYSize)
else:
print("Failed to open the dataset.")
# Define kwargs
kwargs = {
'format': 'GTiff',
'outputSRS': '+proj=latlong +datum=WGS84', # Adjust if needed
'outputBounds': [0.0, -180.0, 360.0, 0.0], # Adjust if needed
'xRes': 1.0,
'yRes': 1.0
}
# Translate the dataset
try:
ds = gdal.Translate(output_path, full_path, **kwargs)
ds = None
print("Translation complete.")
except Exception as e:
print("Error during translation:", e)
i have tried insalling gdal in multiple places, i run the command with shell, it worked. it didnt work with python. i have installed gdal in conda forge, and using jupyter notebook now. i dont understand why they gave the public package if it doesnt want to work no matter how much you try using python.
Jalathota Anisha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.