In [1]:
import numpy
from scipy import ndimage
import pandas
from geoh5 import kea
In this example we initially create a single band image, then append two more.
In [2]:
# data dimensions
dims = (1000, 1000)
# random data
data = numpy.random.ranf(dims)
dtype = data.dtype.name
In [3]:
# define a single output band and add other bands later
kwargs = {'width': dims[1],
'height': dims[0],
'count': 1,
'compression': 4,
'chunks': (100, 100),
'blocksize': 100,
'dtype': dtype}
In [4]:
with kea.open('append-bands-example.kea', 'w', **kwargs) as src:
src.write(data, 1)
# random data
data = numpy.random.ranf(dims)
# add a new band to contain the segments data
src.add_image_band(dtype=dtype, chunks=kwargs['chunks'],
blocksize=kwargs['blocksize'], compression=6,
band_name='Add One')
# write the data
src.write(data, 2)
# random data
data = numpy.random.ranf(dims)
# add a new band to contain the segments data
src.add_image_band(dtype=dtype, chunks=kwargs['chunks'],
blocksize=kwargs['blocksize'], compression=1,
band_name='Then Another')
# write the data
src.write(data, 3)
In [ ]: