| 141 | }}} |
| 142 | |
| 143 | Due to the time it may take to do on-the-fly determination of min/max for large rasters (say 10000 x 10000), an alternative that sacrifices accuracy for speed is required. The following functions sample a percentage of the raster in a methodical randomized manner. The algorithm used for sampling is... |
| 144 | |
| 145 | 1. select the larger dimension of the width and height. compute the number of pixels to sample in each "row" of the larger dimension |
| 146 | |
| 147 | 2. pick pixels from each "row" of the larger dimension in an incremental rolling manner where each increment is randomly determined. |
| 148 | |
| 149 | The functions are: |
| 150 | |
| 151 | 1. ST_ApproxMinMax(rast raster, nband int, ignore_nodata boolean, sample float8) -> record |
| 152 | |
| 153 | sample: a value between 0 and 100 indicating the percentage of the raster band's pixels to consider when determining the min/max pair. |
| 154 | |
| 155 | {{{ |
| 156 | ST_ApproxMinMax(rast, 3, FALSE, 10) |
| 157 | |
| 158 | ST_ApproxMinMax(rast, 1, TRUE, 50) |
| 159 | }}} |
| 160 | |
| 161 | 2. ST_ApproxMinMax(rast raster, ignore_nodata boolean, sample float8) -> record |
| 162 | |
| 163 | assumes that nband = 1 |
| 164 | |
| 165 | {{{ |
| 166 | ST_ApproxMinMax(rast, FALSE, 1) |
| 167 | |
| 168 | ST_ApproxMinMax(rast, TRUE, 2.5) |
| 169 | }}} |
| 170 | |
| 171 | 3. ST_ApproxMinMax(rast raster, sample float8) -> record |
| 172 | |
| 173 | assumes that nband = 1 and ignore_nodata = TRUE |
| 174 | |
| 175 | {{{ |
| 176 | ST_ApproxMinMax(rast, 25) |
| 177 | }}} |
| 178 | |
| 179 | 4. ST_ApproxMinMax(rast raster) -> record |
| 180 | |
| 181 | assumes that nband = 1, ignore_nodata = TRUE and sample = 10 |
| 182 | |
| 183 | {{{ |
| 184 | ST_ApproxMinMax(rast) |