Merge branch 'python' of http://git.normalized.xyz/Florent/Triskele into python

This commit is contained in:
Florent Guiotte 2018-08-23 10:57:46 +02:00
commit 08dda96b06

View File

@ -24,6 +24,10 @@ np_to_gdt = {
def write(fname, X):
"""X.shape = (length, width) or
X.shape = (length, width, samples)"""
fname = Path(fname)
if not fname.parent.exists():
raise IOError('Directory not found: {}'.format(fname.parent))
width = X.shape[1]
length = X.shape[0]
@ -38,7 +42,7 @@ def write(fname, X):
dst_ds = driver.Create(str(fname), width, length, samples, np_to_gdt[X.dtype.type])
for i in range(samples):
dst_ds.GetRasterBand(i + 1).WriteArray(X[:,:,i].astype(np.uint8))
dst_ds.GetRasterBand(i + 1).WriteArray(X[:,:,i])
dst_ds.FlushCache()
def read(fname):