Changes between Version 75 and Version 76 of WKTRaster/SpecificationWorking03


Ignore:
Timestamp:
May 15, 2011, 4:47:53 PM (13 years ago)
Author:
Bborie Park
Comment:

Added ST_SummaryStats

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking03

    v75 v76  
    102102
    103103----
     104
     105'''ST_SummaryStats(raster, nband) -> record'''[[BR]]
     106This is the core function that gets the summary statistics (# of values, mean, standard deviation, minimum value, maximum value) of a specified raster's band.  It is this function that ST_Mean, ST_StdDev and ST_MinMax calls for their appropriate values.
     107
     1081. ST_SummaryStats(rast raster, nband int, hasnodata boolean) -> record
     109
     110  returns one record of five columns (count, mean, stddev, min, max)
     111
     112  nband: index of band
     113
     114  hasnodata: if FALSE, any pixel who's value is nodata is ignored
     115
     116{{{
     117ST_SummaryStats(rast, 1, FALSE)
     118}}}
     119
     1202. ST_SummaryStats(rast raster, nband int) -> record
     121
     122  assumes hasnodata = FALSE
     123
     124{{{
     125ST_SummaryStats(rast, 2)
     126}}}
     127
     1283. ST_SummaryStats(rast raster, hasnodata boolean) -> record
     129
     130  assumes nband = 1
     131
     132{{{
     133ST_SummaryStats(rast, TRUE)
     134}}}
     135
     1364. ST_SummaryStats(rast raster) -> record
     137
     138  assumes nband = 1 and hasnodata = FALSE
     139
     140{{{
     141ST_SummaryStats(rast)
     142}}}
     143
     144Due to the time it may take to do on-the-fly calculation of summary stats 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...
     145
     1461. select the larger dimension of the width and height.  compute the number of pixels to sample in each "row" of the larger dimension
     147
     1482. pick pixels from each "row" of the larger dimension in an incremental rolling manner where each increment is randomly determined.
     149
     150The set of ST_ApproxSummaryStats functions are:
     151
     1521. ST_ApproxSummaryStats(rast raster, nband int, hasnodata boolean, sample_percent double precision) -> record
     153
     154  sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     155
     156{{{
     157ST_ApproxSummaryStats(rast, 3, FALSE, 0.1)
     158
     159ST_ApproxSummaryStats(rast, 1, TRUE, 0.5)
     160}}}
     161
     1622. ST_ApproxSummaryStats(rast raster, nband int, sample_percent double precision) -> record
     163
     164  assumes that nband = 1
     165
     166{{{
     167ST_ApproxSummaryStats(rast, 2 0.01)
     168
     169ST_ApproxSummaryStats(rast, 4, 0.025)
     170}}}
     171
     1723. ST_ApproxSummaryStats(rast raster, hasnodata boolean, sample_percent double precision) -> record
     173
     174  assumes that nband = 1
     175
     176{{{
     177ST_ApproxSummaryStats(rast, FALSE, 0.01)
     178
     179ST_ApproxSummaryStats(rast, TRUE, 0.025)
     180}}}
     181
     1824. ST_ApproxSummaryStats(rast raster, sample_percent double precision) -> record
     183
     184  assumes that nband = 1 and hasnodata = FALSE
     185
     186{{{
     187ST_ApproxSummaryStats(rast, 0.25)
     188}}}
     189
     1905. ST_ApproxSummaryStats(rast raster) -> record
     191
     192  assumes that nband = 1, hasnodata = FALSE and sample_percent = 0.1
     193
     194{{{
     195ST_ApproxSummaryStats(rast)
     196}}}
     197
     198The situation arises where the summary statistics of a coverage table is required.  As the coverage may be large (tens of gigabytes of memory or larger), the following functions are provided to permit an incremental computation of the summary statistics.
     199
     2001. ST_SummaryStats(rastertable text, rastercolumn text, nband int, hasnodata boolean) -> record
     201
     202  rastertable: name of table with raster column
     203
     204  rastercolumn: name of column of data type raster
     205
     206{{{
     207ST_SummaryStats('tmax_2010', 'rast', 1, FALSE)
     208
     209ST_SummaryStats('precip_2011', 'rast', 1, TRUE)
     210}}}
     211
     2122. ST_SummaryStats(rastertable text, rastercolumn text, nband int) -> record
     213
     214    hasnodata = FALSE
     215
     216{{{
     217ST_SummaryStats('tmax_2010', 'rast', 1)
     218}}}
     219
     2203. ST_SummaryStats(rastertable text, rastercolumn text, hasnodata boolean) -> record
     221
     222    nband = 1
     223
     224{{{
     225ST_SummaryStats('precip_2011', 'rast', TRUE)
     226}}}
     227
     2284. ST_SummaryStats(rastertable text, rastercolumn text) -> record
     229
     230    nband = 1 and hasnodata = FALSE
     231
     232{{{
     233ST_SummaryStats('tmin_2009', 'rast')
     234}}}
     235
     236Variations for ST_ApproxSummaryStats are:
     237
     2381. ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, hasnodata boolean, sample_percent double precision) -> record
     239
     240{{{
     241ST_ApproxSummaryStats('tmax_2010', 'rast', 1, FALSE, 0.5)
     242
     243ST_ApproxSummaryStats('precip_2011', 'rast', 1, TRUE, 0.2)
     244}}}
     245
     2462. ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> record
     247
     248    hasnodata = FALSE
     249
     250{{{
     251ST_ApproxSummaryStats('tmax_2010', 'rast', 1, 0.5)
     252
     253ST_ApproxSummaryStats('precip_2011', 'rast', 1, 0.2)
     254}}}
     255
     2563. ST_ApproxSummaryStats(rastertable text, rastercolumn text, hasnodata boolean, sample_percent double precision) -> record
     257
     258    nband = 1
     259
     260{{{
     261ST_ApproxSummaryStats('tmax_2010', 'rast', FALSE, 0.5)
     262
     263ST_ApproxSummaryStats('precip_2011', 'rast', TRUE, 0.2)
     264}}}
     265
     2664. ST_ApproxSummaryStats(rastertable text, rastercolumn text, sample_percent double precision) -> record
     267
     268    nband = 1 and hasnodata = FALSE
     269
     270{{{
     271ST_ApproxSummaryStats('tmax_2010', 'rast', 0.5)
     272
     273ST_ApproxSummaryStats('precip_2011', 'rast', 0.2)
     274}}}
     275
     2765. ST_ApproxSummaryStats(rastertable text, rastercolumn text) -> record
     277
     278    nband = 1, hasnodata = FALSE and sample_percent = 0.1
     279
     280{{{
     281ST_ApproxSummaryStats('tmax_2010', 'rast')
     282
     283ST_ApproxSummaryStats('precip_2011', 'rast')
     284}}}
     285
     286The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is a weighted mean of the means of each raster tile. The standard deviation returned is the cumulative standard deviation of all raster tiles.
     287
     288----
     289
    104290'''ST_MinMax(raster, nband) -> record'''[[BR]]
    105 As part of the process to provide complete implementations of ST_AsJPEG and ST_AsPNG, a method is required to reclassify larger numbers unable to be contained in 8BUI (JPEG and PNG) and 16BUI (PNG). For this reclassification function, we need to get the min and max values of a band, thus ST_MinMax.
     291As part of the process to provide complete implementations of ST_AsJPEG and ST_AsPNG, a method is required to reclassify larger numbers unable to be contained in 8BUI (JPEG and PNG) and 16BUI (PNG). For this reclassification function, we need to get the min and max values of a band, thus ST_MinMax.  This function calls upon ST_SummaryStats.
    106292
    1072931. ST_MinMax(rast raster, nband int, hasnodata boolean) -> record
     
    141327}}}
    142328
    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:
     329The ST_ApproxMinMax functions are:
    150330
    1513311. ST_ApproxMinMax(rast raster, nband int, hasnodata boolean, sample_percent double precision) -> record