0

I would like to save a 3-band raster to file using rasterio.

The official docs have examples for saving a single band image in both the quickstart and in the advanced topics.

What I would like to do is something like..

with rasterio.open('image.tif', 'w', **meta) as dst:
    dst.write(array)

This raises the following error for an array with a shape of (256, 256, 3).

ValueError: Source shape (256, 256, 3) is inconsistent with given indexes 3
1

The numpy array needs to be in bands, rows, cols order (z, y, x) not cols, rows, bands (x, y, z).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.