Changeset 5515 for spike/wktraster/scripts/gdal2wktraster.py
- Timestamp:
- 04/08/10 11:36:39 (2 years ago)
- Files:
-
- 1 modified
-
spike/wktraster/scripts/gdal2wktraster.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
spike/wktraster/scripts/gdal2wktraster.py
r5259 r5515 639 639 nodata = band.GetNoDataValue() 640 640 else: 641 # FIXME: What if input dataset does not specify NODATA value? Zero?642 641 logit("WARNING: No NODATA flagged in raster_columns metadata. " 643 642 "In serialized raster, NODATA bytes will have value of 0.\n") … … 709 708 return hexwkb 710 709 711 def wkblify_band_nodata(band):712 assert band is not None713 714 pixtype = gdt2pt(band.DataType)['id']715 nodata = fetch_band_nodata(band)716 717 hexwkb = ''718 hexwkb += wkblify(pt2fmt(pixtype), nodata)719 720 return hexwkb721 722 710 def wkblify_band_header(options, band): 723 711 """Writes band header into HEX-encoded WKB""" … … 726 714 hexwkb = "" 727 715 716 first4bits = 0 717 718 # If the register option is enabled, set the first bit to 1 719 if options.register: 720 first4bits = 128 721 722 nodata = band.GetNoDataValue() 723 # If there is no nodata value, set it to 0. Otherwise set the HasNodata bit to 1 724 if nodata is not None: 725 first4bits += 64 726 else: 727 nodata = 0 728 728 729 # Encode pixel type 729 730 pixtype = gdt2pt(band.DataType)['id'] 730 if options.register: 731 hexwkb += wkblify('B', pixtype + 128) 732 else: 733 hexwkb += wkblify('B', pixtype) 731 hexwkb += wkblify('B', pixtype + first4bits) 734 732 735 733 # Encode NODATA value (or Zero, if NODATA unavailable) 736 hexwkb += wkblify _band_nodata(band)734 hexwkb += wkblify(pt2fmt(pixtype), nodata) 737 735 738 736 check_hex(hexwkb) … … 758 756 else: 759 757 # In-db raster 760 761 # Real NODATA value or Zero'ed byte(s)762 hexnodata = wkblify_band_nodata(band)763 bytes_per_pixel = len(hexnodata) / 2 # bytes per pixel used to validate hex string764 758 765 759 # Right most column and bottom most row of blocks have
