elham
elham

Reputation: 13

how to create 1 bit per pixel geotiff from binary file in python

My question is: how can I create a geotiff that every pixel of witch represents 1 bit of a raw binary data that comes from input file?

thank you very much

Upvotes: 0

Views: 1021

Answers (1)

Benjamin
Benjamin

Reputation: 11860

In the creation options, use NBITS with the gdal.GDT_Byte data type.

driver = gdal.GetDriverByName('GTiff')
ds_out = driver.Create(path, xsize, ysize, 1, gdal.GDT_Byte, ['NBITS=1'])
ds_out.GetRasterBand(1).WriteArray(myboolarray)
ds_out = None # Close.

See http://www.gdal.org/frmt_gtiff.html, and note that it may not be read properly by some software (such as PCI Geomatica), but should be my most, and by GDAL subsequently.

Upvotes: 2

Related Questions