PostGIS 3.6.2dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ wkblify_band_header()

raster2pgsql.wkblify_band_header (   options,
  band 
)
Writes band header into HEX-encoded WKB

Definition at line 722 of file raster2pgsql.py.

722def wkblify_band_header(options, band):
723 """Writes band header into HEX-encoded WKB"""
724 assert band is not None, "Error: Missing GDAL raster band"
725
726 hexwkb = ""
727
728 first4bits = 0
729
730 # If the register option is enabled, set the first bit to 1
731 if options.register:
732 first4bits = 128
733
734 nodata = band.GetNoDataValue()
735 # If there is no nodata value, set it to 0. Otherwise set the HasNodata bit to 1
736 if nodata is not None:
737 first4bits += 64
738 else:
739 nodata = 0
740
741 # Encode pixel type
742 pixtype = gdt2pt(band.DataType)['id']
743 hexwkb += wkblify('B', pixtype + first4bits)
744
745 # Encode nodata value (or Zero, if nodata unavailable)
746 hexwkb += wkblify(pt2fmt(pixtype), nodata)
747
748 check_hex(hexwkb)
749 return hexwkb
750