Saving Results#

The Layer data is stored within inner NumPy N-dimensional arrays. Therefore, we can utilize any conventional method to save it. In this particular example, we employ the tifffile package.

from rforge import Raster
from rforge import composite

import tifffile

Generating Composite#

file_path = 'file/path/example.tif'

raster = Raster(scale=1)
layer_dict = [
    {'name': 'red', 'id': 1},
    {'name': 'blue', 'id': 2},
    {'name': 'green', 'id': 3},
    {'name': 'alpha', 'id': 4},
]
raster.import_layers(file_path, layer_dict)

layers = [raster.layers['red'], raster.layers['green'], raster.layers['blue']]
gamma = [1, 1, 1]

composite_layer = composite(layers=layers, alpha=raster.layers['alpha'], gamma=gamma)
raster.add_layer(layer=composite_layer, name='rgb')

Saving Layers#

tifffile.imwrite('file/path/example/red.tif', raster.layers['red'].array)
tifffile.imwrite('file/path/example/blue.tif', raster.layers['blue'].array)
tifffile.imwrite('file/path/example/green.tif', raster.layers['green'].array)

Saving Composite#

tifffile.imwrite('file/path/example/rgb.tif', raster.layers['rgb'].array)