Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpostance/dda44bcabbfe5879c9bcd759a1b4bfb5 to your computer and use it in GitHub Desktop.
Save bpostance/dda44bcabbfe5879c9bcd759a1b4bfb5 to your computer and use it in GitHub Desktop.
GDAL Warp
from osgeo import gdal
in_file = f"./modis.hdf" # raw MODIS HDF in sinusoid projection
out_file = f"./modis.tif"
# open dataset
dataset = gdal.Open(in_file,gdal.GA_ReadOnly)
subdataset = gdal.Open(dataset.GetSubDatasets()[0][0], gdal.GA_ReadOnly)
# gdalwarp
kwargs = {'format': 'GTiff', 'dstSRS': 'EPSG:4326'}
ds = gdal.Warp(destNameOrDestDS=out_file,srcDSOrSrcDSTab=subdataset, **kwargs)
del ds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment