Skip to content

Instantly share code, notes, and snippets.

@prl900
Created June 6, 2018 02:00
Show Gist options
  • Save prl900/2306beafc153cc6397fac2afbd366765 to your computer and use it in GitHub Desktop.
Save prl900/2306beafc153cc6397fac2afbd366765 to your computer and use it in GitHub Desktop.
import gdal
from osgeo import osr
import numpy as np
ras = np.load("/Users/pablo/Downloads/test.npy")
drv = gdal.GetDriverByName("GTiff")
ds = drv.Create("/Users/pablo/Downloads/gbdx.tif", 8765, 10000, 1, gdal.GDT_Float32)
proj = osr.SpatialReference()
proj.ImportFromEPSG(4326)
ds.SetProjection(proj.ExportToWkt())
ds.SetGeoTransform(([1.03885169, 2.016708587854833e-05, 0, 40.23778933291412, 0, -2.016708587854833e-05]))
band = ds.GetRasterBand(1)
#band.SetNoDataValue(-1)
band.WriteArray(ras)
ds=None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment