简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM