1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
|
RFC2: Well Known Binary format for RASTER type
----------------------------------------------
Author: Sandro Santilli <strk@kbt.io>
Date: 2009-01-29
Status: Adopted
Revisions:
2011-01-24 by Jorge Arévalo
- Adds isNodataValue bit to band flags
------------------------------------------------------
The WKB format for RASTER is meant for transport.
Takes into account endianness and avoids any padding.
Still, beside padding and endianness, it matches the
internal serialized format (see RFC1), for quick
input/output.
// Basic Type definitions
// byte : 1 byte
// uint16 : 16 bit unsigned integer (2 bytes)
// uint32 : 32 bit unsigned integer (4 bytes)
// float64 : double precision floating point number (8 bytes)
+------------------------------------------------------------+
| RASTER |
+---------------+-------------+------------------------------+
| - name - | - type - | - meaning - |
+---------------+-------------+------------------------------+
| endianness | byte | 1:ndr/little endian |
| | | 0:xdr/big endian |
+---------------+-------------+------------------------------+
| version | uint16 | format version (0 for this |
| | | structure) |
+---------------+-------------+------------------------------+
| nBands | uint16 | Number of bands |
+---------------+-------------+------------------------------+
| scaleX | float64 | pixel width |
| | | in geographical units |
+---------------+-------------+------------------------------+
| scaleY | float64 | pixel height |
| | | in geographical units |
+---------------+-------------+------------------------------+
| ipX | float64 | X ordinate of upper-left |
| | | pixel's upper-left corner |
| | | in geographical units |
+---------------+-------------+------------------------------+
| ipY | float64 | Y ordinate of upper-left |
| | | pixel's upper-left corner |
| | | in geographical units |
+---------------+-------------+------------------------------+
| skewX | float64 | rotation about Y-axis |
+---------------+-------------+------------------------------+
| skewY | float64 | rotation about X-axis |
+---------------+-------------+------------------------------+
| srid | int32 | Spatial reference id |
+---------------+-------------+------------------------------+
| width | uint16 | number of pixel columns |
+---------------+-------------+------------------------------+
| height | uint16 | number of pixel rows |
+---------------+-------------+------------------------------+
| bands[nBands] | RASTERBAND | Bands data |
+---------------+-------------+------------------------------+
+------------------------------------------------------------------+
| RASTERBAND |
+---------------+--------------+-----------------------------------+
| - name - | - type - | - meaning - |
+---------------+--------------+-----------------------------------+
| isOffline | 1bit | If true, data is to be found |
| | | on the filesystem, through the |
| | | path specified in RASTERDATA |
+---------------+--------------+-----------------------------------+
| hasNodataValue| 1bit | If true, stored nodata value is |
| | | a true nodata value. Otherwise |
| | | the value stored as a nodata |
| | | value should be ignored. |
+---------------+--------------+-----------------------------------+
| isNodataValue | 1bit | If true, all the values of the |
| | | band are expected to be nodata |
| | | values. This is a dirty flag. |
| | | To set the flag to its real value |
| | | the function st_bandisnodata must |
| | | must be called for the band with |
| | | 'TRUE' as last argument. |
+---------------+--------------+-----------------------------------+
| reserved | 1bit | unused in this version |
+---------------+--------------+-----------------------------------+
| pixtype | 4bits | 0: 1-bit boolean |
| | | 1: 2-bit unsigned integer |
| | | 2: 4-bit unsigned integer |
| | | 3: 8-bit signed integer |
| | | 4: 8-bit unsigned integer |
| | | 5: 16-bit signed integer |
| | | 6: 16-bit unsigned signed integer |
| | | 7: 32-bit signed integer |
| | | 8: 32-bit unsigned signed integer |
| | | 10: 32-bit float |
| | | 11: 64-bit float |
+---------------+--------------+-----------------------------------+
| nodata | 1 to 8 bytes | Nodata value |
| | depending on | |
| | pixtype [1] | |
+---------------+--------------+-----------------------------------+
| data | RASTERDATA | Raster band data (see below) |
+---------------+--------------+-----------------------------------+
+------------------------------------------------------------------+
| RASTERDATA (isOffline flag clear) |
+---------------+--------------+-----------------------------------+
| pix[w*h] | 1 to 8 bytes | Pixels values, row after row, |
| | depending on | so pix[0] is upper-left, pix[w-1] |
| | pixtype [1] | is upper-right. |
| | | |
| | | As for endianness, it is |
| | | specified at the start of WKB, |
| | | and implicit up to 8bits |
| | | (bit-order is most significant |
| | | first) |
| | | |
+---------------+--------------+-----------------------------------+
[1] 1,2 and 4 bit pixtypes are still encoded as 1-byte per value
+-----------------------------------------------------------------+
| RASTERDATA (isOffline flag set) |
+---------------+-------------+-----------------------------------+
| bandNumber | int8 | 0-based band number to use from |
| | | the set available in the external |
| | | file |
+---------------+-------------+-----------------------------------+
| path | string | null-terminated path to data file |
+---------------+-------------+-----------------------------------+
|