Skip to content

Instantly share code, notes, and snippets.

@hobu
Created August 28, 2018 18:02
Show Gist options
  • Select an option

  • Save hobu/a794edd3918bcd55e9099f22a8c9bdb2 to your computer and use it in GitHub Desktop.

Select an option

Save hobu/a794edd3918bcd55e9099f22a8c9bdb2 to your computer and use it in GitHub Desktop.
options=['COMPRESS=LZW',"BLOCKXSIZE=256", 'TILED=YES', 'COPY_SRC_OVERVIEWS=YES']
driver = gdal.GetDriverByName('GTiff')
outRaster = driver.Create(filename, cols, rows, 2, gdal.GDT_UInt16 , options=options)
outRaster.SetGeoTransform((originX, pixelWidth, 0, originY, 0, pixelHeight))
outband = outRaster.GetRasterBand(1)
outband.WriteArray(array)
zband = outRaster.GetRasterBand(2)
zs = np.empty_like(array)
zs.fill(z)
zband.WriteArray(zs)
outRaster.BuildOverviews( 'nearest', overviewlist = [1, 2, 4])
zband.FlushCache()
outband.FlushCache()
outRaster.FlushCache()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment