Changes between Version 101 and Version 102 of WKTRaster/SpecificationWorking03


Ignore:
Timestamp:
06/13/11 14:00:30 (13 years ago)
Author:
pracine
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • WKTRaster/SpecificationWorking03

    v101 v102  
    771771  4) ST_Intersection(raster, raster, 'geometry') -> geometry -- default both raster to band # 1
    772772
    773 ----
    774 == '''Objective FV.16 - Being able to quickly get raster statistics.''' ==
    775 
    776 '''Add cached basic raster statistic to the base raster WKB format.
    777 
    778 Statistics to be cached should include:
    779 
    780   min/max[[BR]]
    781   mean[[BR]]
    782   standard deviation[[BR]]
    783   histogram[[BR]]
    784   build parameters of stats (sample rate, method used to determine # of bins in histogram?)[[BR]]
    785 
    786 How are the statistics to be kept fresh?  Automatically using some method to see how much of the raster has changed since the last stats calculation?  Or let the user decide?
    787 
    788 ----
    789 
    790 '''ST_SummaryStats(raster, nband) -> record'''[[BR]]
    791 This 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.
    792 
    793 1. ST_SummaryStats(rast raster, nband int, exclude_nodata_value boolean) -> record
    794 
    795   returns one record of five columns (count, mean, stddev, min, max)
    796 
    797   nband: index of band
    798 
    799   exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
    800 
    801 {{{
    802 ST_SummaryStats(rast, 1, FALSE)
    803 }}}
    804 
    805 2. ST_SummaryStats(rast raster, nband int) -> record
    806 
    807   assumes exclude_nodata_value = TRUE
    808 
    809 {{{
    810 ST_SummaryStats(rast, 2)
    811 }}}
    812 
    813 3. ST_SummaryStats(rast raster, exclude_nodata_value boolean) -> record
    814 
    815   assumes nband = 1
    816 
    817 {{{
    818 ST_SummaryStats(rast, TRUE)
    819 }}}
    820 
    821 4. ST_SummaryStats(rast raster) -> record
    822 
    823   assumes nband = 1 and exclude_nodata_value = TRUE
    824 
    825 {{{
    826 ST_SummaryStats(rast)
    827 }}}
    828 
    829 Due 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...
    830 
    831 1. select the larger dimension of the width and height.  compute the number of pixels to sample in each "row" of the larger dimension
    832 
    833 2. pick pixels from each "row" of the larger dimension in an incremental rolling manner where each increment is randomly determined.
    834 
    835 The set of ST_ApproxSummaryStats functions are:
    836 
    837 1. ST_ApproxSummaryStats(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> record
    838 
    839   sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
    840 
    841 {{{
    842 ST_ApproxSummaryStats(rast, 3, FALSE, 0.1)
    843 
    844 ST_ApproxSummaryStats(rast, 1, TRUE, 0.5)
    845 }}}
    846 
    847 2. ST_ApproxSummaryStats(rast raster, nband int, sample_percent double precision) -> record
    848 
    849   assumes that nband = 1
    850 
    851 {{{
    852 ST_ApproxSummaryStats(rast, 2 0.01)
    853 
    854 ST_ApproxSummaryStats(rast, 4, 0.025)
    855 }}}
    856 
    857 3. ST_ApproxSummaryStats(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> record
    858 
    859   assumes that nband = 1
    860 
    861 {{{
    862 ST_ApproxSummaryStats(rast, FALSE, 0.01)
    863 
    864 ST_ApproxSummaryStats(rast, TRUE, 0.025)
    865 }}}
    866 
    867 4. ST_ApproxSummaryStats(rast raster, sample_percent double precision) -> record
    868 
    869   assumes that nband = 1 and exclude_nodata_value = TRUE
    870 
    871 {{{
    872 ST_ApproxSummaryStats(rast, 0.25)
    873 }}}
    874 
    875 5. ST_ApproxSummaryStats(rast raster) -> record
    876 
    877   assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    878 
    879 {{{
    880 ST_ApproxSummaryStats(rast)
    881 }}}
    882 
    883 The 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.
    884 
    885 1. ST_SummaryStats(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> record
    886 
    887   rastertable: name of table with raster column
    888 
    889   rastercolumn: name of column of data type raster
    890 
    891 {{{
    892 ST_SummaryStats('tmax_2010', 'rast', 1, FALSE)
    893 
    894 ST_SummaryStats('precip_2011', 'rast', 1, TRUE)
    895 }}}
    896 
    897 2. ST_SummaryStats(rastertable text, rastercolumn text, nband int) -> record
    898 
    899     exclude_nodata_value = TRUE
    900 
    901 {{{
    902 ST_SummaryStats('tmax_2010', 'rast', 1)
    903 }}}
    904 
    905 3. ST_SummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> record
    906 
    907     nband = 1
    908 
    909 {{{
    910 ST_SummaryStats('precip_2011', 'rast', TRUE)
    911 }}}
    912 
    913 4. ST_SummaryStats(rastertable text, rastercolumn text) -> record
    914 
    915     nband = 1 and exclude_nodata_value = TRUE
    916 
    917 {{{
    918 ST_SummaryStats('tmin_2009', 'rast')
    919 }}}
    920 
    921 Variations for ST_ApproxSummaryStats are:
    922 
    923 1. ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> record
    924 
    925 {{{
    926 ST_ApproxSummaryStats('tmax_2010', 'rast', 1, FALSE, 0.5)
    927 
    928 ST_ApproxSummaryStats('precip_2011', 'rast', 1, TRUE, 0.2)
    929 }}}
    930 
    931 2. ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> record
    932 
    933     exclude_nodata_value = TRUE
    934 
    935 {{{
    936 ST_ApproxSummaryStats('tmax_2010', 'rast', 1, 0.5)
    937 
    938 ST_ApproxSummaryStats('precip_2011', 'rast', 1, 0.2)
    939 }}}
    940 
    941 3. ST_ApproxSummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> record
    942 
    943     nband = 1
    944 
    945 {{{
    946 ST_ApproxSummaryStats('tmax_2010', 'rast', FALSE, 0.5)
    947 
    948 ST_ApproxSummaryStats('precip_2011', 'rast', TRUE, 0.2)
    949 }}}
    950 
    951 4. ST_ApproxSummaryStats(rastertable text, rastercolumn text, sample_percent double precision) -> record
    952 
    953     nband = 1 and exclude_nodata_value = TRUE
    954 
    955 {{{
    956 ST_ApproxSummaryStats('tmax_2010', 'rast', 0.5)
    957 
    958 ST_ApproxSummaryStats('precip_2011', 'rast', 0.2)
    959 }}}
    960 
    961 5. ST_ApproxSummaryStats(rastertable text, rastercolumn text) -> record
    962 
    963     nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    964 
    965 {{{
    966 ST_ApproxSummaryStats('tmax_2010', 'rast')
    967 
    968 ST_ApproxSummaryStats('precip_2011', 'rast')
    969 }}}
    970 
    971 The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is the true mean of the raster tiles. The standard deviation returned is the standard deviation of all raster tiles.
    972 
    973 ----
    974 
    975 '''ST_Count(raster, nband) -> bigint'''[[BR]]
    976 
    977 This function calls ST_SummaryStats and only returns the count from that function.
    978 
    979 1. ST_Count(rast raster, nband int, exclude_nodata_value boolean) -> bigint
    980 
    981     returns the count as an integer
    982 
    983     nband: index of band
    984 
    985     exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
    986 
    987 {{{
    988 ST_Count(rast, 1, FALSE)
    989 }}}
    990 
    991 2. ST_Count(rast raster, nband int) -> bigint
    992 
    993     assumes exclude_nodata_value = TRUE
    994 
    995 {{{
    996 ST_Count(rast, 2)
    997 }}}
    998 
    999 3. ST_Count(rast raster, exclude_nodata_value boolean) -> bigint
    1000 
    1001     assumes nband = 1
    1002 
    1003 {{{
    1004 ST_Count(rast, TRUE)
    1005 }}}
    1006 
    1007 4. ST_Count(rast raster) -> bigint
    1008 
    1009     assumes nband = 1 and exclude_nodata_value = TRUE
    1010 
    1011 {{{
    1012 ST_Count(rast)
    1013 }}}
    1014 
    1015 The set of ST_ApproxCount functions are:
    1016 
    1017 1. ST_ApproxCount(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> bigint
    1018 
    1019     sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
    1020 
    1021 {{{
    1022 ST_ApproxCount(rast, 3, FALSE, 0.1)
    1023 
    1024 ST_ApproxCount(rast, 1, TRUE, 0.5)
    1025 }}}
    1026 
    1027 2. ST_ApproxCount(rast raster, nband int, sample_percent double precision) -> bigint
    1028 
    1029     assumes that nband = 1
    1030 
    1031 {{{
    1032 ST_ApproxCount(rast, 2 0.01)
    1033 
    1034 ST_ApproxCount(rast, 4, 0.025)
    1035 }}}
    1036 
    1037 3. ST_ApproxCount(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> bigint
    1038 
    1039     assumes that nband = 1
    1040 
    1041 {{{
    1042 ST_ApproxCount(rast, FALSE, 0.01)
    1043 
    1044 ST_ApproxCount(rast, TRUE, 0.025)
    1045 }}}
    1046 
    1047 4. ST_ApproxCount(rast raster, sample_percent double precision) -> bigint
    1048 
    1049     assumes that nband = 1 and exclude_nodata_value = TRUE
    1050 
    1051 {{{
    1052 ST_ApproxCount(rast, 0.25)
    1053 }}}
    1054 
    1055 5. ST_ApproxCount(rast raster) -> bigint
    1056 
    1057     assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1058 
    1059 {{{
    1060 ST_ApproxCount(rast)
    1061 }}}
    1062 
    1063 The following functions are provided for coverage tables.
    1064 
    1065 1. ST_Count(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> bigint
    1066 
    1067     rastertable: name of table with raster column
    1068 
    1069     rastercolumn: name of column of data type raster
    1070 
    1071 {{{
    1072 ST_Count('tmax_2010', 'rast', 1, FALSE)
    1073 
    1074 ST_Count('precip_2011', 'rast', 1, TRUE)
    1075 }}}
    1076 
    1077 2. ST_Count(rastertable text, rastercolumn text, nband int) -> bigint
    1078 
    1079     exclude_nodata_value = TRUE
    1080 
    1081 {{{
    1082 ST_Count('tmax_2010', 'rast', 1)
    1083 }}}
    1084 
    1085 3. ST_Count(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> bigint
    1086 
    1087     nband = 1
    1088 
    1089 {{{
    1090 ST_Count('precip_2011', 'rast', TRUE)
    1091 }}}
    1092 
    1093 4. ST_Count(rastertable text, rastercolumn text) -> bigint
    1094 
    1095     nband = 1 and exclude_nodata_value = TRUE
    1096 
    1097 {{{
    1098 ST_Count('tmin_2009', 'rast')
    1099 }}}
    1100 
    1101 Variations for ST_ApproxCount are:
    1102 
    1103 1. ST_ApproxCount(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> bigint
    1104 
    1105 {{{
    1106 ST_ApproxCount('tmax_2010', 'rast', 1, FALSE, 0.5)
    1107 
    1108 ST_ApproxCount('precip_2011', 'rast', 1, TRUE, 0.2)
    1109 }}}
    1110 
    1111 2. ST_ApproxCount(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> bigint
    1112 
    1113     exclude_nodata_value = TRUE
    1114 
    1115 {{{
    1116 ST_ApproxCount('tmax_2010', 'rast', 1, 0.5)
    1117 
    1118 ST_ApproxCount('precip_2011', 'rast', 1, 0.2)
    1119 }}}
    1120 
    1121 3. ST_ApproxCount(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> bigint
    1122 
    1123     nband = 1
    1124 
    1125 {{{
    1126 ST_ApproxCount('tmax_2010', 'rast', FALSE, 0.5)
    1127 
    1128 ST_ApproxCount('precip_2011', 'rast', TRUE, 0.2)
    1129 }}}
    1130 
    1131 4. ST_ApproxCount(rastertable text, rastercolumn text, sample_percent double precision) -> bigint
    1132 
    1133     nband = 1 and exclude_nodata_value = TRUE
    1134 
    1135 {{{
    1136 ST_ApproxCount('tmax_2010', 'rast', 0.5)
    1137 
    1138 ST_ApproxCount('precip_2011', 'rast', 0.2)
    1139 }}}
    1140 
    1141 5. ST_ApproxCount(rastertable text, rastercolumn text) -> bigint
    1142 
    1143     nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1144 
    1145 {{{
    1146 ST_ApproxCount('tmax_2010', 'rast')
    1147 
    1148 ST_ApproxCount('precip_2011', 'rast')
    1149 }}}
    1150 
    1151 ----
    1152 
    1153 '''ST_Sum(raster, nband) -> double precision'''[[BR]]
    1154 
    1155 This function calls ST_SummaryStats and only returns the sum from that function.
    1156 
    1157 1. ST_Sum(rast raster, nband int, exclude_nodata_value boolean) -> double precision
    1158 
    1159     returns the sum as an integer
    1160 
    1161     nband: index of band
    1162 
    1163     exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
    1164 
    1165 {{{
    1166 ST_Sum(rast, 1, FALSE)
    1167 }}}
    1168 
    1169 2. ST_Sum(rast raster, nband int) -> double precision
    1170 
    1171     assumes exclude_nodata_value = TRUE
    1172 
    1173 {{{
    1174 ST_Sum(rast, 2)
    1175 }}}
    1176 
    1177 3. ST_Sum(rast raster, exclude_nodata_value boolean) -> double precision
    1178 
    1179     assumes nband = 1
    1180 
    1181 {{{
    1182 ST_Sum(rast, TRUE)
    1183 }}}
    1184 
    1185 4. ST_Sum(rast raster) -> double precision
    1186 
    1187     assumes nband = 1 and exclude_nodata_value = TRUE
    1188 
    1189 {{{
    1190 ST_Sum(rast)
    1191 }}}
    1192 
    1193 The set of ST_ApproxSum functions are:
    1194 
    1195 1. ST_ApproxSum(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1196 
    1197     sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
    1198 
    1199 {{{
    1200 ST_ApproxSum(rast, 3, FALSE, 0.1)
    1201 
    1202 ST_ApproxSum(rast, 1, TRUE, 0.5)
    1203 }}}
    1204 
    1205 2. ST_ApproxSum(rast raster, nband int, sample_percent double precision) -> double precision
    1206 
    1207     assumes that nband = 1
    1208 
    1209 {{{
    1210 ST_ApproxSum(rast, 2 0.01)
    1211 
    1212 ST_ApproxSum(rast, 4, 0.025)
    1213 }}}
    1214 
    1215 3. ST_ApproxSum(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1216 
    1217     assumes that nband = 1
    1218 
    1219 {{{
    1220 ST_ApproxSum(rast, FALSE, 0.01)
    1221 
    1222 ST_ApproxSum(rast, TRUE, 0.025)
    1223 }}}
    1224 
    1225 4. ST_ApproxSum(rast raster, sample_percent double precision) -> double precision
    1226 
    1227     assumes that nband = 1 and exclude_nodata_value = TRUE
    1228 
    1229 {{{
    1230 ST_ApproxSum(rast, 0.25)
    1231 }}}
    1232 
    1233 5. ST_ApproxSum(rast raster) -> double precision
    1234 
    1235     assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1236 
    1237 {{{
    1238 ST_ApproxSum(rast)
    1239 }}}
    1240 
    1241 The following functions are provided for coverage tables.
    1242 
    1243 1. ST_Sum(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> double precision
    1244 
    1245     rastertable: name of table with raster column
    1246 
    1247     rastercolumn: name of column of data type raster
    1248 
    1249 {{{
    1250 ST_Sum('tmax_2010', 'rast', 1, FALSE)
    1251 
    1252 ST_Sum('precip_2011', 'rast', 1, TRUE)
    1253 }}}
    1254 
    1255 2. ST_Sum(rastertable text, rastercolumn text, nband int) -> double precision
    1256 
    1257     exclude_nodata_value = TRUE
    1258 
    1259 {{{
    1260 ST_Sum('tmax_2010', 'rast', 1)
    1261 }}}
    1262 
    1263 3. ST_Sum(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> double precision
    1264 
    1265     nband = 1
    1266 
    1267 {{{
    1268 ST_Sum('precip_2011', 'rast', TRUE)
    1269 }}}
    1270 
    1271 4. ST_Sum(rastertable text, rastercolumn text) -> double precision
    1272 
    1273     nband = 1 and exclude_nodata_value = TRUE
    1274 
    1275 {{{
    1276 ST_Sum('tmin_2009', 'rast')
    1277 }}}
    1278 
    1279 Variations for ST_ApproxSum are:
    1280 
    1281 1. ST_ApproxSum(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1282 
    1283 {{{
    1284 ST_ApproxSum('tmax_2010', 'rast', 1, FALSE, 0.5)
    1285 
    1286 ST_ApproxSum('precip_2011', 'rast', 1, TRUE, 0.2)
    1287 }}}
    1288 
    1289 2. ST_ApproxSum(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> double precision
    1290 
    1291     exclude_nodata_value = TRUE
    1292 
    1293 {{{
    1294 ST_ApproxSum('tmax_2010', 'rast', 1, 0.5)
    1295 
    1296 ST_ApproxSum('precip_2011', 'rast', 1, 0.2)
    1297 }}}
    1298 
    1299 3. ST_ApproxSum(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1300 
    1301     nband = 1
    1302 
    1303 {{{
    1304 ST_ApproxSum('tmax_2010', 'rast', FALSE, 0.5)
    1305 
    1306 ST_ApproxSum('precip_2011', 'rast', TRUE, 0.2)
    1307 }}}
    1308 
    1309 4. ST_ApproxSum(rastertable text, rastercolumn text, sample_percent double precision) -> double precision
    1310 
    1311     nband = 1 and exclude_nodata_value = TRUE
    1312 
    1313 {{{
    1314 ST_ApproxSum('tmax_2010', 'rast', 0.5)
    1315 
    1316 ST_ApproxSum('precip_2011', 'rast', 0.2)
    1317 }}}
    1318 
    1319 5. ST_ApproxSum(rastertable text, rastercolumn text) -> double precision
    1320 
    1321     nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1322 
    1323 {{{
    1324 ST_ApproxSum('tmax_2010', 'rast')
    1325 
    1326 ST_ApproxSum('precip_2011', 'rast')
    1327 }}}
    1328 
    1329 ----
    1330 
    1331 '''ST_Mean(raster, nband) -> double precision'''[[BR]]
    1332 This function calls ST_SummaryStats and only returns the mean from that function.
    1333 
    1334 1. ST_Mean(rast raster, nband int, exclude_nodata_value boolean) -> double precision
    1335 
    1336   returns the mean as a double precision
    1337 
    1338   nband: index of band
    1339 
    1340   exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
    1341 
    1342 {{{
    1343 ST_Mean(rast, 1, FALSE)
    1344 }}}
    1345 
    1346 2. ST_Mean(rast raster, nband int) -> double precision
    1347 
    1348   assumes exclude_nodata_value = TRUE
    1349 
    1350 {{{
    1351 ST_Mean(rast, 2)
    1352 }}}
    1353 
    1354 3. ST_Mean(rast raster, exclude_nodata_value boolean) -> double precision
    1355 
    1356   assumes nband = 1
    1357 
    1358 {{{
    1359 ST_Mean(rast, TRUE)
    1360 }}}
    1361 
    1362 4. ST_Mean(rast raster) -> double precision
    1363 
    1364   assumes nband = 1 and exclude_nodata_value = TRUE
    1365 
    1366 {{{
    1367 ST_Mean(rast)
    1368 }}}
    1369 
    1370 The set of ST_ApproxMean functions are:
    1371 
    1372 1. ST_ApproxMean(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1373 
    1374   sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
    1375 
    1376 {{{
    1377 ST_ApproxMean(rast, 3, FALSE, 0.1)
    1378 
    1379 ST_ApproxMean(rast, 1, TRUE, 0.5)
    1380 }}}
    1381 
    1382 2. ST_ApproxMean(rast raster, nband int, sample_percent double precision) -> double precision
    1383 
    1384   assumes that nband = 1
    1385 
    1386 {{{
    1387 ST_ApproxMean(rast, 2 0.01)
    1388 
    1389 ST_ApproxMean(rast, 4, 0.025)
    1390 }}}
    1391 
    1392 3. ST_ApproxMean(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1393 
    1394   assumes that nband = 1
    1395 
    1396 {{{
    1397 ST_ApproxMean(rast, FALSE, 0.01)
    1398 
    1399 ST_ApproxMean(rast, TRUE, 0.025)
    1400 }}}
    1401 
    1402 4. ST_ApproxMean(rast raster, sample_percent double precision) -> double precision
    1403 
    1404   assumes that nband = 1 and exclude_nodata_value = TRUE
    1405 
    1406 {{{
    1407 ST_ApproxMean(rast, 0.25)
    1408 }}}
    1409 
    1410 5. ST_ApproxMean(rast raster) -> double precision
    1411 
    1412   assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1413 
    1414 {{{
    1415 ST_ApproxMean(rast)
    1416 }}}
    1417 
    1418 The following functions are provided for coverage tables.
    1419 
    1420 1. ST_Mean(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> double precision
    1421 
    1422   rastertable: name of table with raster column
    1423 
    1424   rastercolumn: name of column of data type raster
    1425 
    1426 {{{
    1427 ST_Mean('tmax_2010', 'rast', 1, FALSE)
    1428 
    1429 ST_Mean('precip_2011', 'rast', 1, TRUE)
    1430 }}}
    1431 
    1432 2. ST_Mean(rastertable text, rastercolumn text, nband int) -> double precision
    1433 
    1434     exclude_nodata_value = TRUE
    1435 
    1436 {{{
    1437 ST_Mean('tmax_2010', 'rast', 1)
    1438 }}}
    1439 
    1440 3. ST_Mean(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> double precision
    1441 
    1442     nband = 1
    1443 
    1444 {{{
    1445 ST_Mean('precip_2011', 'rast', TRUE)
    1446 }}}
    1447 
    1448 4. ST_Mean(rastertable text, rastercolumn text) -> double precision
    1449 
    1450     nband = 1 and exclude_nodata_value = TRUE
    1451 
    1452 {{{
    1453 ST_Mean('tmin_2009', 'rast')
    1454 }}}
    1455 
    1456 Variations for ST_ApproxMean are:
    1457 
    1458 1. ST_ApproxMean(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1459 
    1460 {{{
    1461 ST_ApproxMean('tmax_2010', 'rast', 1, FALSE, 0.5)
    1462 
    1463 ST_ApproxMean('precip_2011', 'rast', 1, TRUE, 0.2)
    1464 }}}
    1465 
    1466 2. ST_ApproxMean(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> double precision
    1467 
    1468     exclude_nodata_value = TRUE
    1469 
    1470 {{{
    1471 ST_ApproxMean('tmax_2010', 'rast', 1, 0.5)
    1472 
    1473 ST_ApproxMean('precip_2011', 'rast', 1, 0.2)
    1474 }}}
    1475 
    1476 3. ST_ApproxMean(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1477 
    1478     nband = 1
    1479 
    1480 {{{
    1481 ST_ApproxMean('tmax_2010', 'rast', FALSE, 0.5)
    1482 
    1483 ST_ApproxMean('precip_2011', 'rast', TRUE, 0.2)
    1484 }}}
    1485 
    1486 4. ST_ApproxMean(rastertable text, rastercolumn text, sample_percent double precision) -> double precision
    1487 
    1488     nband = 1 and exclude_nodata_value = TRUE
    1489 
    1490 {{{
    1491 ST_ApproxMean('tmax_2010', 'rast', 0.5)
    1492 
    1493 ST_ApproxMean('precip_2011', 'rast', 0.2)
    1494 }}}
    1495 
    1496 5. ST_ApproxMean(rastertable text, rastercolumn text) -> double precision
    1497 
    1498     nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1499 
    1500 {{{
    1501 ST_ApproxMean('tmax_2010', 'rast')
    1502 
    1503 ST_ApproxMean('precip_2011', 'rast')
    1504 }}}
    1505 
    1506 The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is the true mean of the raster tiles.
    1507 
    1508 ----
    1509 
    1510 '''ST_StdDev(raster, nband) -> double precision'''[[BR]]
    1511 This function calls ST_SummaryStats and only returns the standard deviation from that function.
    1512 
    1513 1. ST_StdDev(rast raster, nband int, exclude_nodata_value boolean) -> double precision
    1514 
    1515   returns the standard deviation as a double precision
    1516 
    1517   nband: index of band
    1518 
    1519   exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
    1520 
    1521 {{{
    1522 ST_StdDev(rast, 1, FALSE)
    1523 }}}
    1524 
    1525 2. ST_StdDev(rast raster, nband int) -> double precision
    1526 
    1527   assumes exclude_nodata_value = TRUE
    1528 
    1529 {{{
    1530 ST_StdDev(rast, 2)
    1531 }}}
    1532 
    1533 3. ST_StdDev(rast raster, exclude_nodata_value boolean) -> double precision
    1534 
    1535   assumes nband = 1
    1536 
    1537 {{{
    1538 ST_StdDev(rast, TRUE)
    1539 }}}
    1540 
    1541 4. ST_StdDev(rast raster) -> double precision
    1542 
    1543   assumes nband = 1 and exclude_nodata_value = TRUE
    1544 
    1545 {{{
    1546 ST_StdDev(rast)
    1547 }}}
    1548 
    1549 The set of ST_ApproxStdDev functions are:
    1550 
    1551 1. ST_ApproxStdDev(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1552 
    1553   sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
    1554 
    1555 {{{
    1556 ST_ApproxStdDev(rast, 3, FALSE, 0.1)
    1557 
    1558 ST_ApproxStdDev(rast, 1, TRUE, 0.5)
    1559 }}}
    1560 
    1561 2. ST_ApproxStdDev(rast raster, nband int, sample_percent double precision) -> double precision
    1562 
    1563   assumes that nband = 1
    1564 
    1565 {{{
    1566 ST_ApproxStdDev(rast, 2 0.01)
    1567 
    1568 ST_ApproxStdDev(rast, 4, 0.025)
    1569 }}}
    1570 
    1571 3. ST_ApproxStdDev(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1572 
    1573   assumes that nband = 1
    1574 
    1575 {{{
    1576 ST_ApproxStdDev(rast, FALSE, 0.01)
    1577 
    1578 ST_ApproxStdDev(rast, TRUE, 0.025)
    1579 }}}
    1580 
    1581 4. ST_ApproxStdDev(rast raster, sample_percent double precision) -> double precision
    1582 
    1583   assumes that nband = 1 and exclude_nodata_value = TRUE
    1584 
    1585 {{{
    1586 ST_ApproxStdDev(rast, 0.25)
    1587 }}}
    1588 
    1589 5. ST_ApproxStdDev(rast raster) -> double precision
    1590 
    1591   assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1592 
    1593 {{{
    1594 ST_ApproxStdDev(rast)
    1595 }}}
    1596 
    1597 The following functions are provided for coverage tables.
    1598 
    1599 1. ST_StdDev(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> double precision
    1600 
    1601   rastertable: name of table with raster column
    1602 
    1603   rastercolumn: name of column of data type raster
    1604 
    1605 {{{
    1606 ST_StdDev('tmax_2010', 'rast', 1, FALSE)
    1607 
    1608 ST_StdDev('precip_2011', 'rast', 1, TRUE)
    1609 }}}
    1610 
    1611 2. ST_StdDev(rastertable text, rastercolumn text, nband int) -> double precision
    1612 
    1613     exclude_nodata_value = TRUE
    1614 
    1615 {{{
    1616 ST_StdDev('tmax_2010', 'rast', 1)
    1617 }}}
    1618 
    1619 3. ST_StdDev(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> double precision
    1620 
    1621     nband = 1
    1622 
    1623 {{{
    1624 ST_StdDev('precip_2011', 'rast', TRUE)
    1625 }}}
    1626 
    1627 4. ST_StdDev(rastertable text, rastercolumn text) -> double precision
    1628 
    1629     nband = 1 and exclude_nodata_value = TRUE
    1630 
    1631 {{{
    1632 ST_StdDev('tmin_2009', 'rast')
    1633 }}}
    1634 
    1635 Variations for ST_ApproxStdDev are:
    1636 
    1637 1. ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1638 
    1639 {{{
    1640 ST_ApproxStdDev('tmax_2010', 'rast', 1, FALSE, 0.5)
    1641 
    1642 ST_ApproxStdDev('precip_2011', 'rast', 1, TRUE, 0.2)
    1643 }}}
    1644 
    1645 2. ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> double precision
    1646 
    1647     exclude_nodata_value = TRUE
    1648 
    1649 {{{
    1650 ST_ApproxStdDev('tmax_2010', 'rast', 1, 0.5)
    1651 
    1652 ST_ApproxStdDev('precip_2011', 'rast', 1, 0.2)
    1653 }}}
    1654 
    1655 3. ST_ApproxStdDev(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> double precision
    1656 
    1657     nband = 1
    1658 
    1659 {{{
    1660 ST_ApproxStdDev('tmax_2010', 'rast', FALSE, 0.5)
    1661 
    1662 ST_ApproxStdDev('precip_2011', 'rast', TRUE, 0.2)
    1663 }}}
    1664 
    1665 4. ST_ApproxStdDev(rastertable text, rastercolumn text, sample_percent double precision) -> double precision
    1666 
    1667     nband = 1 and exclude_nodata_value = TRUE
    1668 
    1669 {{{
    1670 ST_ApproxStdDev('tmax_2010', 'rast', 0.5)
    1671 
    1672 ST_ApproxStdDev('precip_2011', 'rast', 0.2)
    1673 }}}
    1674 
    1675 5. ST_ApproxStdDev(rastertable text, rastercolumn text) -> double precision
    1676 
    1677     nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1678 
    1679 {{{
    1680 ST_ApproxStdDev('tmax_2010', 'rast')
    1681 
    1682 ST_ApproxStdDev('precip_2011', 'rast')
    1683 }}}
    1684 
    1685 The standard deviation returned in the coverage functions (has rastertable and rastercolumn arguments) is the standard deviation of all raster tiles.
    1686 
    1687 ----
    1688 
    1689 '''ST_MinMax(raster, nband) -> record'''[[BR]]
    1690 This function calls ST_SummaryStats and only returns the min and max values from that function.
    1691 
    1692 1. ST_MinMax(rast raster, nband int, exclude_nodata_value boolean) -> record
    1693 
    1694   returns the record (min double precision, max double precision)
    1695 
    1696   nband: index of band
    1697 
    1698   exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
    1699 
    1700 {{{
    1701 ST_MinMax(rast, 1, FALSE)
    1702 }}}
    1703 
    1704 2. ST_MinMax(rast raster, nband int) -> record
    1705 
    1706   assumes exclude_nodata_value = TRUE
    1707 
    1708 {{{
    1709 ST_MinMax(rast, 2)
    1710 }}}
    1711 
    1712 3. ST_MinMax(rast raster, exclude_nodata_value boolean) -> record
    1713 
    1714   assumes nband = 1
    1715 
    1716 {{{
    1717 ST_MinMax(rast, TRUE)
    1718 }}}
    1719 
    1720 4. ST_MinMax(rast raster) -> record
    1721 
    1722   assumes nband = 1 and exclude_nodata_value = TRUE
    1723 
    1724 {{{
    1725 ST_MinMax(rast)
    1726 }}}
    1727 
    1728 The set of ST_ApproxMinMax functions are:
    1729 
    1730 1. ST_ApproxMinMax(rast raster, nband int, exclude_nodata_value boolean, sample_percent record) -> record
    1731 
    1732   sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
    1733 
    1734 {{{
    1735 ST_ApproxMinMax(rast, 3, FALSE, 0.1)
    1736 
    1737 ST_ApproxMinMax(rast, 1, TRUE, 0.5)
    1738 }}}
    1739 
    1740 2. ST_ApproxMinMax(rast raster, nband int, sample_percent double precision) -> record
    1741 
    1742   assumes that nband = 1
    1743 
    1744 {{{
    1745 ST_ApproxMinMax(rast, 2 0.01)
    1746 
    1747 ST_ApproxMinMax(rast, 4, 0.025)
    1748 }}}
    1749 
    1750 3. ST_ApproxMinMax(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> record
    1751 
    1752   assumes that nband = 1
    1753 
    1754 {{{
    1755 ST_ApproxMinMax(rast, FALSE, 0.01)
    1756 
    1757 ST_ApproxMinMax(rast, TRUE, 0.025)
    1758 }}}
    1759 
    1760 4. ST_ApproxMinMax(rast raster, sample_percent double precision) -> record
    1761 
    1762   assumes that nband = 1 and exclude_nodata_value = TRUE
    1763 
    1764 {{{
    1765 ST_ApproxMinMax(rast, 0.25)
    1766 }}}
    1767 
    1768 5. ST_ApproxMinMax(rast raster) -> record
    1769 
    1770   assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1771 
    1772 {{{
    1773 ST_ApproxMinMax(rast)
    1774 }}}
    1775 
    1776 The following functions are provided for coverage tables.
    1777 
    1778 1. ST_MinMax(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> record
    1779 
    1780   rastertable: name of table with raster column
    1781 
    1782   rastercolumn: name of column of data type raster
    1783 
    1784 {{{
    1785 ST_MinMax('tmax_2010', 'rast', 1, FALSE)
    1786 
    1787 ST_MinMax('precip_2011', 'rast', 1, TRUE)
    1788 }}}
    1789 
    1790 2. ST_MinMax(rastertable text, rastercolumn text, nband int) -> record
    1791 
    1792     exclude_nodata_value = TRUE
    1793 
    1794 {{{
    1795 ST_MinMax('tmax_2010', 'rast', 1)
    1796 }}}
    1797 
    1798 3. ST_MinMax(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> record
    1799 
    1800     nband = 1
    1801 
    1802 {{{
    1803 ST_MinMax('precip_2011', 'rast', TRUE)
    1804 }}}
    1805 
    1806 4. ST_MinMax(rastertable text, rastercolumn text) -> record
    1807 
    1808     nband = 1 and exclude_nodata_value = TRUE
    1809 
    1810 {{{
    1811 ST_MinMax('tmin_2009', 'rast')
    1812 }}}
    1813 
    1814 Variations for ST_ApproxMinMax are:
    1815 
    1816 1. ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> record
    1817 
    1818 {{{
    1819 ST_ApproxMinMax('tmax_2010', 'rast', 1, FALSE, 0.5)
    1820 
    1821 ST_ApproxMinMax('precip_2011', 'rast', 1, TRUE, 0.2)
    1822 }}}
    1823 
    1824 2. ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> record
    1825 
    1826     exclude_nodata_value = TRUE
    1827 
    1828 {{{
    1829 ST_ApproxMinMax('tmax_2010', 'rast', 1, 0.5)
    1830 
    1831 ST_ApproxMinMax('precip_2011', 'rast', 1, 0.2)
    1832 }}}
    1833 
    1834 3. ST_ApproxMinMax(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> record
    1835 
    1836     nband = 1
    1837 
    1838 {{{
    1839 ST_ApproxMinMax('tmax_2010', 'rast', FALSE, 0.5)
    1840 
    1841 ST_ApproxMinMax('precip_2011', 'rast', TRUE, 0.2)
    1842 }}}
    1843 
    1844 4. ST_ApproxMinMax(rastertable text, rastercolumn text, sample_percent double precision) -> record
    1845 
    1846     nband = 1 and exclude_nodata_value = TRUE
    1847 
    1848 {{{
    1849 ST_ApproxMinMax('tmax_2010', 'rast', 0.5)
    1850 
    1851 ST_ApproxMinMax('precip_2011', 'rast', 0.2)
    1852 }}}
    1853 
    1854 5. ST_ApproxMinMax(rastertable text, rastercolumn text) -> record
    1855 
    1856     nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
    1857 
    1858 {{{
    1859 ST_ApproxMinMax('tmax_2010', 'rast')
    1860 
    1861 ST_ApproxMinMax('precip_2011', 'rast')
    1862 }}}
    1863 
    1864 ----
    1865 
    1866 '''ST_Histogram(raster, nband) -> set of records'''[[BR]]
    1867 ST_Histogram and ST_ApproxHistogram provide methods to determine a raster's data distribution.
    1868 
    1869 The return of ST_Histogram and ST_ApproxHistogram is a set of records where each record is (min, max, count, percent).
    1870 
    1871 ST_Histogram has the following variations.
    1872 
    1873 1. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, width double precision[], right boolean) -> set of records
    1874 
    1875   returns set of records of four columns (min, max, count, percent)
    1876 
    1877   nband: index of band to process on
    1878 
    1879   exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
    1880 
    1881   bins: the number of categories/bins to have in the histogram. If NULL or value less than one, the number of categories will be auto-computed using Sturges' formula if the number of values >= 30 or Square-root choice if number of values < 30.
    1882 
    1883     http://en.wikipedia.org/wiki/Histogram#Mathematical_definition
    1884 
    1885   width: an array indicating the width of each category/bin. If the number of bins is greater than the number of widths, the widths are repeated. Example: 9 bins, widths are [a, b, c] will have the output be [a, b, c, a, b, c, a, b, c].
    1886 
    1887   right: compute the histogram from the right rather than from the left (default). This changes the criteria for evaluating a value x from [a, b) to (a, b].
    1888 
    1889 {{{
    1890 ST_Histogram(rast, 2, FALSE, NULL, NULL, FALSE)
    1891 
    1892 ST_Histogram(rast, 1, TRUE, 100, NULL, FALSE)
    1893 
    1894 ST_Histogram(rast, 2, FALSE, NULL, ARRAY[100, 50], FALSE)
    1895 
    1896 ST_Histogram(rast, 2, FALSE, 9, ARRAY[1000], TRUE)
    1897 
    1898 ST_Histogram(rast, 2, FALSE, 20, ARRAY[100, 200, 300], TRUE)
    1899 }}}
    1900 
    1901 2. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, right boolean) -> set of records
    1902 
    1903   parameter "width" is not specified thus resulting in all bins having the same widths
    1904 
    1905 {{{
    1906 ST_Histogram(rast, 2, FALSE, 5, FALSE)
    1907 }}}
    1908 
    1909 3. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int) -> set of records
    1910 
    1911   the parameter "right" is removed and assumed to be FALSE
    1912 
    1913 {{{
    1914 ST_Histogram(rast, 2, FALSE, 5)
    1915 }}}
    1916 
    1917 4. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean) -> set of records
    1918 
    1919   the parameter "bins" is removed and set to NULL.  The function will compute the number of bins to use
    1920 
    1921 5. ST_Histogram(rast raster, nband int) -> set of records
    1922 
    1923   exclude_nodata_value is assumed to be TRUE
    1924 
    1925 6. ST_Histogram(rast raster) -> set of records
    1926 
    1927   assumes that nband is 1.
    1928 
    1929 7. ST_Histogram(rast raster, nband int, bins int, width double precision[], right boolean) -> set of records
    1930 
    1931   exclude_nodata_value is assumed to be TRUE
    1932 
    1933 8. ST_Histogram(rast raster, nband int, bins int, right boolean) -> set of records
    1934 
    1935   all bins will have equal widths
    1936 
    1937 9. ST_Histogram(rast raster, nband int, bins int) -> set of records
    1938 
    1939   right is assumed to be FALSE
    1940 
    1941 ST_ApproxHistogram should have the following variations.
    1942 
    1943 1. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, width double precision[], right boolean) -> set of record
    1944 
    1945     sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider when generating the histogram.
    1946 
    1947 {{{
    1948 ST_Histogram(rast, 2, FALSE, 0.1, NULL, NULL, FALSE)
    1949 
    1950 ST_Histogram(rast, 1, TRUE, 1, 100, NULL, FALSE)
    1951 
    1952 ST_Histogram(rast, 2, FALSE, 0.2, NULL, ARRAY[100, 50], FALSE)
    1953 
    1954 ST_Histogram(rast, 2, FALSE, 0.25, 9, ARRAY[1000], TRUE)
    1955 
    1956 ST_Histogram(rast, 2, FALSE, 0.05, 20, ARRAY[100, 200, 300], TRUE)
    1957 }}}
    1958 
    1959 2. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean) -> set of records
    1960 
    1961   parameter "width" is not specified thus resulting in all bins having the same widths
    1962 
    1963 3. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int) -> set of records
    1964 
    1965   the parameter "right" is removed and assumed to be FALSE
    1966 
    1967 {{{
    1968 ST_ApproxHistogram(rast, 2, FALSE, 5)
    1969 }}}
    1970 
    1971 4. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> set of records
    1972 
    1973   the parameter "bins" is removed and set to NULL so that function can compute the number of bins to use
    1974 
    1975 5. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision) -> set of records
    1976 
    1977   exclude_nodata_value is assumed to be TRUE
    1978 
    1979 6. ST_ApproxHistogram(rast raster, nband int) -> set of records
    1980 
    1981   assumes that sample_percent is 0.1
    1982 
    1983 7. ST_ApproxHistogram(rast raster, sample_percent double_precision) -> set of records
    1984 
    1985   assumes that nband is 1
    1986 
    1987 8. ST_ApproxHistogram(rast raster) -> set of records
    1988 
    1989   assumes that nband is 1 and sample_percent is 0.1
    1990 
    1991 9. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int, width double precision[], right boolean) -> set of records
    1992 
    1993   exclude_nodata_value is assumed to be TRUE
    1994 
    1995 10. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int, right boolean) -> set of records
    1996 
    1997   all bins will have equal widths
    1998 
    1999 11. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int) -> set of records
    2000 
    2001   right is assumed to be FALSE
    2002 
    2003 The following set of function are for coverages.
    2004 
    2005 1. ST_Histogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int default 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) -> set of records
    2006 
    2007   rastertable: name of table with raster column
    2008 
    2009   rastercolumn: name of column of data type raster
    2010 
    2011 {{{
    2012 ST_Histogram('tmax_2010', 'rast')
    2013 
    2014 ST_Histogram('precip_2011', 'rast', 1)
    2015 
    2016 ST_Histogram('precip_2011', 'rast', 1, FALSE)
    2017 
    2018 ST_Histogram('precip_2011', 'rast', 1, FALSE, 5)
    2019 
    2020 ST_Histogram('precip_2011', 'rast', 1, FALSE, 10, NULL)
    2021 
    2022 ST_Histogram('precip_2011', 'rast', 1, FALSE, 10, NULL, TRUE)
    2023 }}}
    2024 
    2025 2. ST_Histogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, bins int, right boolean) -> set of records
    2026 
    2027 {{{
    2028 ST_Histogram('tmin_2010', 'rast', 2, FALSE, 5, FALSE)
    2029 }}}
    2030 
    2031 3. ST_Histogram(rastertable text, rastercolumn text, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) -> set of records
    2032 
    2033 {{{
    2034 ST_Histogram('ndvi_2010', 'rast', 1, 5)
    2035 
    2036 ST_Histogram('ndvi_2010', 'rast', 1, 0, ARRAY[0.5]::double precision[])
    2037 
    2038 ST_Histogram('ndvi_2010', 'rast', 1, 5, NULL, TRUE)
    2039 }}}
    2040 
    2041 4. ST_Histogram(rastertable text, rastercolumn text, nband int, bins int, right boolean) -> set of records
    2042 
    2043 {{{
    2044 ST_Histogram('veg_2009', 'rast', 2, 3, FALSE)
    2045 
    2046 ST_Histogram('veg_2009', 'rast', 2, 3, TRUE)
    2047 }}}
    2048 
    2049 A set of functions of ST_ApproxHistogram for coverage tables:
    2050 
    2051 1. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) -> set of records
    2052 
    2053 {{{
    2054 ST_ApproxHistogram('precip_2010', 'rast')
    2055 
    2056 ST_ApproxHistogram('precip_2010', 'rast', 1)
    2057 
    2058 ST_ApproxHistogram('precip_2010', 'rast', 2, FALSE)
    2059 
    2060 ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.25)
    2061 
    2062 ST_ApproxHistogram('precip_2010', 'rast', 3, FALSE, 0.2, 10)
    2063 
    2064 ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.1, 0, ARRAY[1]::double precision[])
    2065 
    2066 ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.1, 0, ARRAY[1]::double precision[], FALSE)
    2067 }}}
    2068 
    2069 2. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean)
    2070 
    2071 3. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision)
    2072 
    2073 4. ST_ApproxHistogram(rastertable text, rastercolumn text, sample_percent double precision)
    2074 
    2075 5. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
    2076 
    2077 6. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, right boolean)
    2078 
    2079 ----
    2080 '''ST_Quantile(raster, nband) -> set of records'''[[BR]]
    2081 In addition to determining the histogram of a raster, providing the ability to compute quantiles permits a user to reference a value in the context of the sample or population. Thus, a value could be examined to be at the raster's 25%, 50%, 75% percentile.
    2082 
    2083 http://en.wikipedia.org/wiki/Quantile
    2084 
    2085 ST_Quantile variations:
    2086 
    2087 1. ST_Quantile(rast raster, nband int, exclude_nodata_value boolean, quantiles double precision[]) -> set of records
    2088 
    2089   each row returned is of (quantile double precision, value double precision)
    2090 
    2091   nband: index of band to process on
    2092 
    2093   exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
    2094 
    2095   quantiles: array of percentages to compute values for
    2096 
    2097 {{{
    2098 ST_Quantile(rast, 1, FALSE, ARRAY[0.1, 0.3, 0.7])
    2099 
    2100 ST_Quantile(rast, 1, TRUE, ARRAY[0.2])
    2101 
    2102 ST_Quantile(rast, 1, FALSE, ARRAY[0, 1])
    2103 }}}
    2104 
    2105 2. ST_Quantile(rast raster, nband int, quantiles double precision[]) -> set of records
    2106 
    2107   "exclude_nodata_value" is assumed to be TRUE
    2108 
    2109 {{{
    2110 ST_Quantile(rast, 1, ARRAY[0.1, 0.3, 0.7])
    2111 }}}
    2112 
    2113 3. ST_Quantile(rast raster, nband int, exclude_nodata_value boolean) -> set of records
    2114 
    2115   "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
    2116 
    2117 4. ST_Quantile(rast raster, nband int) -> set of records
    2118 
    2119   "exclude_nodata_value" is assumed to be TRUE and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
    2120 
    2121 5. ST_Quantile(rast raster, quantiles double precision[]) -> set of records
    2122 
    2123   "nband" is assumed to be 1 and "exclude_nodata_value" is TRUE
    2124 
    2125 6. ST_Quantile(rast raster) -> set of records
    2126 
    2127   "nband" is assumed to be 1 and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
    2128 
    2129 7. ST_Quantile(rast raster, nband int, exclude_nodata_value boolean, quantile double precision) -> record
    2130 
    2131   quantile: the single percentile to compute
    2132 
    2133 8. ST_Quantile(rast raster, nband int, quantile double precision) -> record
    2134 
    2135   "exclude_nodata_value" is assumed to be TRUE
    2136 
    2137 9. ST_Quantile(rast raster, exclude_nodata_value boolean, quantile double precision) -> record
    2138 
    2139   "nband" is assumed to be 1
    2140 
    2141 10. ST_Quantile(rast raster, quantile double precision) -> record
    2142 
    2143   "nband" is assumed to be 1  and "exclude_nodata_value" is assumed to be TRUE
    2144 
    2145 ST_ApproxQuantile adds a "sample_percent" indicating the percentage of the raster to sample
    2146 
    2147 1. ST_ApproxQuantile(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, quantiles double precision[]) -> set of records
    2148 
    2149   nband: index of band to process on
    2150 
    2151   exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
    2152 
    2153   sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider when computing the quantiles
    2154 
    2155   quantiles: array of percentages to compute values for
    2156 
    2157 {{{
    2158 ST_ApproxQuantile(rast, 1, FALSE, 0.1, ARRAY[0.1, 0.3, 0.7])
    2159 
    2160 ST_ApproxQuantile(rast, 1, TRUE, .2, ARRAY[0.2])
    2161 
    2162 ST_ApproxQuantile(rast, 1, FALSE, 0.3, ARRAY[0, 1])
    2163 }}}
    2164 
    2165 2. ST_ApproxQuantile(rast raster, nband int, sample_percent double precision, quantiles double precision[]) -> set of records
    2166 
    2167   "exclude_nodata_value" is assumed to be TRUE
    2168 
    2169 {{{
    2170 ST_ApproxQuantile(rast, 1, .05, ARRAY[0.1, 0.3, 0.7])
    2171 }}}
    2172 
    2173 3. ST_ApproxQuantile(rast raster, nband int, sample_percent double precision) -> set of records
    2174 
    2175   "exclude_nodata_value" is assumed to be TRUE and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
    2176 
    2177 4. ST_ApproxQuantile(rast raster, sample_percent double precision, quantiles double precision[]) -> set of records
    2178 
    2179   "nband" is assumed to be 1
    2180 
    2181 5. ST_ApproxQuantile(rast raster, nband int, sample_percent double precision, quantile double precision) -> record
    2182 
    2183   quantile: the single percentile to compute
    2184 
    2185 6. ST_ApproxQuantile(rast raster, sample_percent double precision, quantile double precision) -> record
    2186 
    2187   "nband" is assumed to be 2
    2188 
    2189 7. ST_ApproxQuantile(rast raster, sample_percent double precision) -> set of records
    2190 
    2191   "nband" is assumed to be 1 and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
    2192 
    2193 8. ST_ApproxQuantile(rast raster, nband int, quantile double precision) -> record
    2194 
    2195   "sample_percent" assumed to be 0.1
    2196 
    2197 9. ST_ApproxQuantile(rast raster, quantiles double precision[]) -> set of records
    2198 
    2199   "nband" is assumed to be 1 and "sample_percent" assumed to be 0.1
    2200 
    2201 10. ST_ApproxQuantile(rast raster, quantile double precision) -> record
    2202 
    2203   "nband" assumed to be 1 and "sample_percent" assumed to be 0.1
    2204 
    2205 11. ST_ApproxQuantile(rast raster, nband int) -> set of records
    2206 
    2207   "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1] and "sample_percent" assumed to be 0.1
    2208 
    2209 12. ST_ApproxQuantile(rast raster) -> set of records
    2210 
    2211   "nband" is assumed to be 1, "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1] and "sample_percent" assumed to be 0.1
     773
    2212774
    2213775----
     
    29101472ST_Reclass(rast, '0-100:0-10', '8BUI', 11)
    29111473}}}
     1474
     1475----
     1476== '''Objective FV.16 - Being able to quickly get raster statistics.''' ==
     1477
     1478'''Add cached basic raster statistic to the base raster WKB format.
     1479
     1480Statistics to be cached should include:
     1481
     1482  min/max[[BR]]
     1483  mean[[BR]]
     1484  standard deviation[[BR]]
     1485  histogram[[BR]]
     1486  build parameters of stats (sample rate, method used to determine # of bins in histogram?)[[BR]]
     1487
     1488How are the statistics to be kept fresh?  Automatically using some method to see how much of the raster has changed since the last stats calculation?  Or let the user decide?
     1489
     1490----
     1491
     1492'''ST_SummaryStats(raster, nband) -> record'''[[BR]]
     1493This 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.
     1494
     14951. ST_SummaryStats(rast raster, nband int, exclude_nodata_value boolean) -> record
     1496
     1497  returns one record of five columns (count, mean, stddev, min, max)
     1498
     1499  nband: index of band
     1500
     1501  exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
     1502
     1503{{{
     1504ST_SummaryStats(rast, 1, FALSE)
     1505}}}
     1506
     15072. ST_SummaryStats(rast raster, nband int) -> record
     1508
     1509  assumes exclude_nodata_value = TRUE
     1510
     1511{{{
     1512ST_SummaryStats(rast, 2)
     1513}}}
     1514
     15153. ST_SummaryStats(rast raster, exclude_nodata_value boolean) -> record
     1516
     1517  assumes nband = 1
     1518
     1519{{{
     1520ST_SummaryStats(rast, TRUE)
     1521}}}
     1522
     15234. ST_SummaryStats(rast raster) -> record
     1524
     1525  assumes nband = 1 and exclude_nodata_value = TRUE
     1526
     1527{{{
     1528ST_SummaryStats(rast)
     1529}}}
     1530
     1531Due 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...
     1532
     15331. select the larger dimension of the width and height.  compute the number of pixels to sample in each "row" of the larger dimension
     1534
     15352. pick pixels from each "row" of the larger dimension in an incremental rolling manner where each increment is randomly determined.
     1536
     1537The set of ST_ApproxSummaryStats functions are:
     1538
     15391. ST_ApproxSummaryStats(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> record
     1540
     1541  sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     1542
     1543{{{
     1544ST_ApproxSummaryStats(rast, 3, FALSE, 0.1)
     1545
     1546ST_ApproxSummaryStats(rast, 1, TRUE, 0.5)
     1547}}}
     1548
     15492. ST_ApproxSummaryStats(rast raster, nband int, sample_percent double precision) -> record
     1550
     1551  assumes that nband = 1
     1552
     1553{{{
     1554ST_ApproxSummaryStats(rast, 2 0.01)
     1555
     1556ST_ApproxSummaryStats(rast, 4, 0.025)
     1557}}}
     1558
     15593. ST_ApproxSummaryStats(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> record
     1560
     1561  assumes that nband = 1
     1562
     1563{{{
     1564ST_ApproxSummaryStats(rast, FALSE, 0.01)
     1565
     1566ST_ApproxSummaryStats(rast, TRUE, 0.025)
     1567}}}
     1568
     15694. ST_ApproxSummaryStats(rast raster, sample_percent double precision) -> record
     1570
     1571  assumes that nband = 1 and exclude_nodata_value = TRUE
     1572
     1573{{{
     1574ST_ApproxSummaryStats(rast, 0.25)
     1575}}}
     1576
     15775. ST_ApproxSummaryStats(rast raster) -> record
     1578
     1579  assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     1580
     1581{{{
     1582ST_ApproxSummaryStats(rast)
     1583}}}
     1584
     1585The 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.
     1586
     15871. ST_SummaryStats(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> record
     1588
     1589  rastertable: name of table with raster column
     1590
     1591  rastercolumn: name of column of data type raster
     1592
     1593{{{
     1594ST_SummaryStats('tmax_2010', 'rast', 1, FALSE)
     1595
     1596ST_SummaryStats('precip_2011', 'rast', 1, TRUE)
     1597}}}
     1598
     15992. ST_SummaryStats(rastertable text, rastercolumn text, nband int) -> record
     1600
     1601    exclude_nodata_value = TRUE
     1602
     1603{{{
     1604ST_SummaryStats('tmax_2010', 'rast', 1)
     1605}}}
     1606
     16073. ST_SummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> record
     1608
     1609    nband = 1
     1610
     1611{{{
     1612ST_SummaryStats('precip_2011', 'rast', TRUE)
     1613}}}
     1614
     16154. ST_SummaryStats(rastertable text, rastercolumn text) -> record
     1616
     1617    nband = 1 and exclude_nodata_value = TRUE
     1618
     1619{{{
     1620ST_SummaryStats('tmin_2009', 'rast')
     1621}}}
     1622
     1623Variations for ST_ApproxSummaryStats are:
     1624
     16251. ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> record
     1626
     1627{{{
     1628ST_ApproxSummaryStats('tmax_2010', 'rast', 1, FALSE, 0.5)
     1629
     1630ST_ApproxSummaryStats('precip_2011', 'rast', 1, TRUE, 0.2)
     1631}}}
     1632
     16332. ST_ApproxSummaryStats(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> record
     1634
     1635    exclude_nodata_value = TRUE
     1636
     1637{{{
     1638ST_ApproxSummaryStats('tmax_2010', 'rast', 1, 0.5)
     1639
     1640ST_ApproxSummaryStats('precip_2011', 'rast', 1, 0.2)
     1641}}}
     1642
     16433. ST_ApproxSummaryStats(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> record
     1644
     1645    nband = 1
     1646
     1647{{{
     1648ST_ApproxSummaryStats('tmax_2010', 'rast', FALSE, 0.5)
     1649
     1650ST_ApproxSummaryStats('precip_2011', 'rast', TRUE, 0.2)
     1651}}}
     1652
     16534. ST_ApproxSummaryStats(rastertable text, rastercolumn text, sample_percent double precision) -> record
     1654
     1655    nband = 1 and exclude_nodata_value = TRUE
     1656
     1657{{{
     1658ST_ApproxSummaryStats('tmax_2010', 'rast', 0.5)
     1659
     1660ST_ApproxSummaryStats('precip_2011', 'rast', 0.2)
     1661}}}
     1662
     16635. ST_ApproxSummaryStats(rastertable text, rastercolumn text) -> record
     1664
     1665    nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     1666
     1667{{{
     1668ST_ApproxSummaryStats('tmax_2010', 'rast')
     1669
     1670ST_ApproxSummaryStats('precip_2011', 'rast')
     1671}}}
     1672
     1673The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is the true mean of the raster tiles. The standard deviation returned is the standard deviation of all raster tiles.
     1674
     1675----
     1676
     1677'''ST_Count(raster, nband) -> bigint'''[[BR]]
     1678
     1679This function calls ST_SummaryStats and only returns the count from that function.
     1680
     16811. ST_Count(rast raster, nband int, exclude_nodata_value boolean) -> bigint
     1682
     1683    returns the count as an integer
     1684
     1685    nband: index of band
     1686
     1687    exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
     1688
     1689{{{
     1690ST_Count(rast, 1, FALSE)
     1691}}}
     1692
     16932. ST_Count(rast raster, nband int) -> bigint
     1694
     1695    assumes exclude_nodata_value = TRUE
     1696
     1697{{{
     1698ST_Count(rast, 2)
     1699}}}
     1700
     17013. ST_Count(rast raster, exclude_nodata_value boolean) -> bigint
     1702
     1703    assumes nband = 1
     1704
     1705{{{
     1706ST_Count(rast, TRUE)
     1707}}}
     1708
     17094. ST_Count(rast raster) -> bigint
     1710
     1711    assumes nband = 1 and exclude_nodata_value = TRUE
     1712
     1713{{{
     1714ST_Count(rast)
     1715}}}
     1716
     1717The set of ST_ApproxCount functions are:
     1718
     17191. ST_ApproxCount(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> bigint
     1720
     1721    sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     1722
     1723{{{
     1724ST_ApproxCount(rast, 3, FALSE, 0.1)
     1725
     1726ST_ApproxCount(rast, 1, TRUE, 0.5)
     1727}}}
     1728
     17292. ST_ApproxCount(rast raster, nband int, sample_percent double precision) -> bigint
     1730
     1731    assumes that nband = 1
     1732
     1733{{{
     1734ST_ApproxCount(rast, 2 0.01)
     1735
     1736ST_ApproxCount(rast, 4, 0.025)
     1737}}}
     1738
     17393. ST_ApproxCount(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> bigint
     1740
     1741    assumes that nband = 1
     1742
     1743{{{
     1744ST_ApproxCount(rast, FALSE, 0.01)
     1745
     1746ST_ApproxCount(rast, TRUE, 0.025)
     1747}}}
     1748
     17494. ST_ApproxCount(rast raster, sample_percent double precision) -> bigint
     1750
     1751    assumes that nband = 1 and exclude_nodata_value = TRUE
     1752
     1753{{{
     1754ST_ApproxCount(rast, 0.25)
     1755}}}
     1756
     17575. ST_ApproxCount(rast raster) -> bigint
     1758
     1759    assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     1760
     1761{{{
     1762ST_ApproxCount(rast)
     1763}}}
     1764
     1765The following functions are provided for coverage tables.
     1766
     17671. ST_Count(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> bigint
     1768
     1769    rastertable: name of table with raster column
     1770
     1771    rastercolumn: name of column of data type raster
     1772
     1773{{{
     1774ST_Count('tmax_2010', 'rast', 1, FALSE)
     1775
     1776ST_Count('precip_2011', 'rast', 1, TRUE)
     1777}}}
     1778
     17792. ST_Count(rastertable text, rastercolumn text, nband int) -> bigint
     1780
     1781    exclude_nodata_value = TRUE
     1782
     1783{{{
     1784ST_Count('tmax_2010', 'rast', 1)
     1785}}}
     1786
     17873. ST_Count(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> bigint
     1788
     1789    nband = 1
     1790
     1791{{{
     1792ST_Count('precip_2011', 'rast', TRUE)
     1793}}}
     1794
     17954. ST_Count(rastertable text, rastercolumn text) -> bigint
     1796
     1797    nband = 1 and exclude_nodata_value = TRUE
     1798
     1799{{{
     1800ST_Count('tmin_2009', 'rast')
     1801}}}
     1802
     1803Variations for ST_ApproxCount are:
     1804
     18051. ST_ApproxCount(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> bigint
     1806
     1807{{{
     1808ST_ApproxCount('tmax_2010', 'rast', 1, FALSE, 0.5)
     1809
     1810ST_ApproxCount('precip_2011', 'rast', 1, TRUE, 0.2)
     1811}}}
     1812
     18132. ST_ApproxCount(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> bigint
     1814
     1815    exclude_nodata_value = TRUE
     1816
     1817{{{
     1818ST_ApproxCount('tmax_2010', 'rast', 1, 0.5)
     1819
     1820ST_ApproxCount('precip_2011', 'rast', 1, 0.2)
     1821}}}
     1822
     18233. ST_ApproxCount(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> bigint
     1824
     1825    nband = 1
     1826
     1827{{{
     1828ST_ApproxCount('tmax_2010', 'rast', FALSE, 0.5)
     1829
     1830ST_ApproxCount('precip_2011', 'rast', TRUE, 0.2)
     1831}}}
     1832
     18334. ST_ApproxCount(rastertable text, rastercolumn text, sample_percent double precision) -> bigint
     1834
     1835    nband = 1 and exclude_nodata_value = TRUE
     1836
     1837{{{
     1838ST_ApproxCount('tmax_2010', 'rast', 0.5)
     1839
     1840ST_ApproxCount('precip_2011', 'rast', 0.2)
     1841}}}
     1842
     18435. ST_ApproxCount(rastertable text, rastercolumn text) -> bigint
     1844
     1845    nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     1846
     1847{{{
     1848ST_ApproxCount('tmax_2010', 'rast')
     1849
     1850ST_ApproxCount('precip_2011', 'rast')
     1851}}}
     1852
     1853----
     1854
     1855'''ST_Sum(raster, nband) -> double precision'''[[BR]]
     1856
     1857This function calls ST_SummaryStats and only returns the sum from that function.
     1858
     18591. ST_Sum(rast raster, nband int, exclude_nodata_value boolean) -> double precision
     1860
     1861    returns the sum as an integer
     1862
     1863    nband: index of band
     1864
     1865    exclude_nodata_value: if FALSE, nodata values in band are included in the stats. if TRUE, nodata values are not included
     1866
     1867{{{
     1868ST_Sum(rast, 1, FALSE)
     1869}}}
     1870
     18712. ST_Sum(rast raster, nband int) -> double precision
     1872
     1873    assumes exclude_nodata_value = TRUE
     1874
     1875{{{
     1876ST_Sum(rast, 2)
     1877}}}
     1878
     18793. ST_Sum(rast raster, exclude_nodata_value boolean) -> double precision
     1880
     1881    assumes nband = 1
     1882
     1883{{{
     1884ST_Sum(rast, TRUE)
     1885}}}
     1886
     18874. ST_Sum(rast raster) -> double precision
     1888
     1889    assumes nband = 1 and exclude_nodata_value = TRUE
     1890
     1891{{{
     1892ST_Sum(rast)
     1893}}}
     1894
     1895The set of ST_ApproxSum functions are:
     1896
     18971. ST_ApproxSum(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     1898
     1899    sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     1900
     1901{{{
     1902ST_ApproxSum(rast, 3, FALSE, 0.1)
     1903
     1904ST_ApproxSum(rast, 1, TRUE, 0.5)
     1905}}}
     1906
     19072. ST_ApproxSum(rast raster, nband int, sample_percent double precision) -> double precision
     1908
     1909    assumes that nband = 1
     1910
     1911{{{
     1912ST_ApproxSum(rast, 2 0.01)
     1913
     1914ST_ApproxSum(rast, 4, 0.025)
     1915}}}
     1916
     19173. ST_ApproxSum(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     1918
     1919    assumes that nband = 1
     1920
     1921{{{
     1922ST_ApproxSum(rast, FALSE, 0.01)
     1923
     1924ST_ApproxSum(rast, TRUE, 0.025)
     1925}}}
     1926
     19274. ST_ApproxSum(rast raster, sample_percent double precision) -> double precision
     1928
     1929    assumes that nband = 1 and exclude_nodata_value = TRUE
     1930
     1931{{{
     1932ST_ApproxSum(rast, 0.25)
     1933}}}
     1934
     19355. ST_ApproxSum(rast raster) -> double precision
     1936
     1937    assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     1938
     1939{{{
     1940ST_ApproxSum(rast)
     1941}}}
     1942
     1943The following functions are provided for coverage tables.
     1944
     19451. ST_Sum(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> double precision
     1946
     1947    rastertable: name of table with raster column
     1948
     1949    rastercolumn: name of column of data type raster
     1950
     1951{{{
     1952ST_Sum('tmax_2010', 'rast', 1, FALSE)
     1953
     1954ST_Sum('precip_2011', 'rast', 1, TRUE)
     1955}}}
     1956
     19572. ST_Sum(rastertable text, rastercolumn text, nband int) -> double precision
     1958
     1959    exclude_nodata_value = TRUE
     1960
     1961{{{
     1962ST_Sum('tmax_2010', 'rast', 1)
     1963}}}
     1964
     19653. ST_Sum(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> double precision
     1966
     1967    nband = 1
     1968
     1969{{{
     1970ST_Sum('precip_2011', 'rast', TRUE)
     1971}}}
     1972
     19734. ST_Sum(rastertable text, rastercolumn text) -> double precision
     1974
     1975    nband = 1 and exclude_nodata_value = TRUE
     1976
     1977{{{
     1978ST_Sum('tmin_2009', 'rast')
     1979}}}
     1980
     1981Variations for ST_ApproxSum are:
     1982
     19831. ST_ApproxSum(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     1984
     1985{{{
     1986ST_ApproxSum('tmax_2010', 'rast', 1, FALSE, 0.5)
     1987
     1988ST_ApproxSum('precip_2011', 'rast', 1, TRUE, 0.2)
     1989}}}
     1990
     19912. ST_ApproxSum(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> double precision
     1992
     1993    exclude_nodata_value = TRUE
     1994
     1995{{{
     1996ST_ApproxSum('tmax_2010', 'rast', 1, 0.5)
     1997
     1998ST_ApproxSum('precip_2011', 'rast', 1, 0.2)
     1999}}}
     2000
     20013. ST_ApproxSum(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2002
     2003    nband = 1
     2004
     2005{{{
     2006ST_ApproxSum('tmax_2010', 'rast', FALSE, 0.5)
     2007
     2008ST_ApproxSum('precip_2011', 'rast', TRUE, 0.2)
     2009}}}
     2010
     20114. ST_ApproxSum(rastertable text, rastercolumn text, sample_percent double precision) -> double precision
     2012
     2013    nband = 1 and exclude_nodata_value = TRUE
     2014
     2015{{{
     2016ST_ApproxSum('tmax_2010', 'rast', 0.5)
     2017
     2018ST_ApproxSum('precip_2011', 'rast', 0.2)
     2019}}}
     2020
     20215. ST_ApproxSum(rastertable text, rastercolumn text) -> double precision
     2022
     2023    nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2024
     2025{{{
     2026ST_ApproxSum('tmax_2010', 'rast')
     2027
     2028ST_ApproxSum('precip_2011', 'rast')
     2029}}}
     2030
     2031----
     2032
     2033'''ST_Mean(raster, nband) -> double precision'''[[BR]]
     2034This function calls ST_SummaryStats and only returns the mean from that function.
     2035
     20361. ST_Mean(rast raster, nband int, exclude_nodata_value boolean) -> double precision
     2037
     2038  returns the mean as a double precision
     2039
     2040  nband: index of band
     2041
     2042  exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
     2043
     2044{{{
     2045ST_Mean(rast, 1, FALSE)
     2046}}}
     2047
     20482. ST_Mean(rast raster, nband int) -> double precision
     2049
     2050  assumes exclude_nodata_value = TRUE
     2051
     2052{{{
     2053ST_Mean(rast, 2)
     2054}}}
     2055
     20563. ST_Mean(rast raster, exclude_nodata_value boolean) -> double precision
     2057
     2058  assumes nband = 1
     2059
     2060{{{
     2061ST_Mean(rast, TRUE)
     2062}}}
     2063
     20644. ST_Mean(rast raster) -> double precision
     2065
     2066  assumes nband = 1 and exclude_nodata_value = TRUE
     2067
     2068{{{
     2069ST_Mean(rast)
     2070}}}
     2071
     2072The set of ST_ApproxMean functions are:
     2073
     20741. ST_ApproxMean(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2075
     2076  sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     2077
     2078{{{
     2079ST_ApproxMean(rast, 3, FALSE, 0.1)
     2080
     2081ST_ApproxMean(rast, 1, TRUE, 0.5)
     2082}}}
     2083
     20842. ST_ApproxMean(rast raster, nband int, sample_percent double precision) -> double precision
     2085
     2086  assumes that nband = 1
     2087
     2088{{{
     2089ST_ApproxMean(rast, 2 0.01)
     2090
     2091ST_ApproxMean(rast, 4, 0.025)
     2092}}}
     2093
     20943. ST_ApproxMean(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2095
     2096  assumes that nband = 1
     2097
     2098{{{
     2099ST_ApproxMean(rast, FALSE, 0.01)
     2100
     2101ST_ApproxMean(rast, TRUE, 0.025)
     2102}}}
     2103
     21044. ST_ApproxMean(rast raster, sample_percent double precision) -> double precision
     2105
     2106  assumes that nband = 1 and exclude_nodata_value = TRUE
     2107
     2108{{{
     2109ST_ApproxMean(rast, 0.25)
     2110}}}
     2111
     21125. ST_ApproxMean(rast raster) -> double precision
     2113
     2114  assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2115
     2116{{{
     2117ST_ApproxMean(rast)
     2118}}}
     2119
     2120The following functions are provided for coverage tables.
     2121
     21221. ST_Mean(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> double precision
     2123
     2124  rastertable: name of table with raster column
     2125
     2126  rastercolumn: name of column of data type raster
     2127
     2128{{{
     2129ST_Mean('tmax_2010', 'rast', 1, FALSE)
     2130
     2131ST_Mean('precip_2011', 'rast', 1, TRUE)
     2132}}}
     2133
     21342. ST_Mean(rastertable text, rastercolumn text, nband int) -> double precision
     2135
     2136    exclude_nodata_value = TRUE
     2137
     2138{{{
     2139ST_Mean('tmax_2010', 'rast', 1)
     2140}}}
     2141
     21423. ST_Mean(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> double precision
     2143
     2144    nband = 1
     2145
     2146{{{
     2147ST_Mean('precip_2011', 'rast', TRUE)
     2148}}}
     2149
     21504. ST_Mean(rastertable text, rastercolumn text) -> double precision
     2151
     2152    nband = 1 and exclude_nodata_value = TRUE
     2153
     2154{{{
     2155ST_Mean('tmin_2009', 'rast')
     2156}}}
     2157
     2158Variations for ST_ApproxMean are:
     2159
     21601. ST_ApproxMean(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2161
     2162{{{
     2163ST_ApproxMean('tmax_2010', 'rast', 1, FALSE, 0.5)
     2164
     2165ST_ApproxMean('precip_2011', 'rast', 1, TRUE, 0.2)
     2166}}}
     2167
     21682. ST_ApproxMean(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> double precision
     2169
     2170    exclude_nodata_value = TRUE
     2171
     2172{{{
     2173ST_ApproxMean('tmax_2010', 'rast', 1, 0.5)
     2174
     2175ST_ApproxMean('precip_2011', 'rast', 1, 0.2)
     2176}}}
     2177
     21783. ST_ApproxMean(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2179
     2180    nband = 1
     2181
     2182{{{
     2183ST_ApproxMean('tmax_2010', 'rast', FALSE, 0.5)
     2184
     2185ST_ApproxMean('precip_2011', 'rast', TRUE, 0.2)
     2186}}}
     2187
     21884. ST_ApproxMean(rastertable text, rastercolumn text, sample_percent double precision) -> double precision
     2189
     2190    nband = 1 and exclude_nodata_value = TRUE
     2191
     2192{{{
     2193ST_ApproxMean('tmax_2010', 'rast', 0.5)
     2194
     2195ST_ApproxMean('precip_2011', 'rast', 0.2)
     2196}}}
     2197
     21985. ST_ApproxMean(rastertable text, rastercolumn text) -> double precision
     2199
     2200    nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2201
     2202{{{
     2203ST_ApproxMean('tmax_2010', 'rast')
     2204
     2205ST_ApproxMean('precip_2011', 'rast')
     2206}}}
     2207
     2208The mean returned in the coverage functions (has rastertable and rastercolumn arguments) is the true mean of the raster tiles.
     2209
     2210----
     2211
     2212'''ST_StdDev(raster, nband) -> double precision'''[[BR]]
     2213This function calls ST_SummaryStats and only returns the standard deviation from that function.
     2214
     22151. ST_StdDev(rast raster, nband int, exclude_nodata_value boolean) -> double precision
     2216
     2217  returns the standard deviation as a double precision
     2218
     2219  nband: index of band
     2220
     2221  exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
     2222
     2223{{{
     2224ST_StdDev(rast, 1, FALSE)
     2225}}}
     2226
     22272. ST_StdDev(rast raster, nband int) -> double precision
     2228
     2229  assumes exclude_nodata_value = TRUE
     2230
     2231{{{
     2232ST_StdDev(rast, 2)
     2233}}}
     2234
     22353. ST_StdDev(rast raster, exclude_nodata_value boolean) -> double precision
     2236
     2237  assumes nband = 1
     2238
     2239{{{
     2240ST_StdDev(rast, TRUE)
     2241}}}
     2242
     22434. ST_StdDev(rast raster) -> double precision
     2244
     2245  assumes nband = 1 and exclude_nodata_value = TRUE
     2246
     2247{{{
     2248ST_StdDev(rast)
     2249}}}
     2250
     2251The set of ST_ApproxStdDev functions are:
     2252
     22531. ST_ApproxStdDev(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2254
     2255  sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     2256
     2257{{{
     2258ST_ApproxStdDev(rast, 3, FALSE, 0.1)
     2259
     2260ST_ApproxStdDev(rast, 1, TRUE, 0.5)
     2261}}}
     2262
     22632. ST_ApproxStdDev(rast raster, nband int, sample_percent double precision) -> double precision
     2264
     2265  assumes that nband = 1
     2266
     2267{{{
     2268ST_ApproxStdDev(rast, 2 0.01)
     2269
     2270ST_ApproxStdDev(rast, 4, 0.025)
     2271}}}
     2272
     22733. ST_ApproxStdDev(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2274
     2275  assumes that nband = 1
     2276
     2277{{{
     2278ST_ApproxStdDev(rast, FALSE, 0.01)
     2279
     2280ST_ApproxStdDev(rast, TRUE, 0.025)
     2281}}}
     2282
     22834. ST_ApproxStdDev(rast raster, sample_percent double precision) -> double precision
     2284
     2285  assumes that nband = 1 and exclude_nodata_value = TRUE
     2286
     2287{{{
     2288ST_ApproxStdDev(rast, 0.25)
     2289}}}
     2290
     22915. ST_ApproxStdDev(rast raster) -> double precision
     2292
     2293  assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2294
     2295{{{
     2296ST_ApproxStdDev(rast)
     2297}}}
     2298
     2299The following functions are provided for coverage tables.
     2300
     23011. ST_StdDev(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> double precision
     2302
     2303  rastertable: name of table with raster column
     2304
     2305  rastercolumn: name of column of data type raster
     2306
     2307{{{
     2308ST_StdDev('tmax_2010', 'rast', 1, FALSE)
     2309
     2310ST_StdDev('precip_2011', 'rast', 1, TRUE)
     2311}}}
     2312
     23132. ST_StdDev(rastertable text, rastercolumn text, nband int) -> double precision
     2314
     2315    exclude_nodata_value = TRUE
     2316
     2317{{{
     2318ST_StdDev('tmax_2010', 'rast', 1)
     2319}}}
     2320
     23213. ST_StdDev(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> double precision
     2322
     2323    nband = 1
     2324
     2325{{{
     2326ST_StdDev('precip_2011', 'rast', TRUE)
     2327}}}
     2328
     23294. ST_StdDev(rastertable text, rastercolumn text) -> double precision
     2330
     2331    nband = 1 and exclude_nodata_value = TRUE
     2332
     2333{{{
     2334ST_StdDev('tmin_2009', 'rast')
     2335}}}
     2336
     2337Variations for ST_ApproxStdDev are:
     2338
     23391. ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2340
     2341{{{
     2342ST_ApproxStdDev('tmax_2010', 'rast', 1, FALSE, 0.5)
     2343
     2344ST_ApproxStdDev('precip_2011', 'rast', 1, TRUE, 0.2)
     2345}}}
     2346
     23472. ST_ApproxStdDev(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> double precision
     2348
     2349    exclude_nodata_value = TRUE
     2350
     2351{{{
     2352ST_ApproxStdDev('tmax_2010', 'rast', 1, 0.5)
     2353
     2354ST_ApproxStdDev('precip_2011', 'rast', 1, 0.2)
     2355}}}
     2356
     23573. ST_ApproxStdDev(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> double precision
     2358
     2359    nband = 1
     2360
     2361{{{
     2362ST_ApproxStdDev('tmax_2010', 'rast', FALSE, 0.5)
     2363
     2364ST_ApproxStdDev('precip_2011', 'rast', TRUE, 0.2)
     2365}}}
     2366
     23674. ST_ApproxStdDev(rastertable text, rastercolumn text, sample_percent double precision) -> double precision
     2368
     2369    nband = 1 and exclude_nodata_value = TRUE
     2370
     2371{{{
     2372ST_ApproxStdDev('tmax_2010', 'rast', 0.5)
     2373
     2374ST_ApproxStdDev('precip_2011', 'rast', 0.2)
     2375}}}
     2376
     23775. ST_ApproxStdDev(rastertable text, rastercolumn text) -> double precision
     2378
     2379    nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2380
     2381{{{
     2382ST_ApproxStdDev('tmax_2010', 'rast')
     2383
     2384ST_ApproxStdDev('precip_2011', 'rast')
     2385}}}
     2386
     2387The standard deviation returned in the coverage functions (has rastertable and rastercolumn arguments) is the standard deviation of all raster tiles.
     2388
     2389----
     2390
     2391'''ST_MinMax(raster, nband) -> record'''[[BR]]
     2392This function calls ST_SummaryStats and only returns the min and max values from that function.
     2393
     23941. ST_MinMax(rast raster, nband int, exclude_nodata_value boolean) -> record
     2395
     2396  returns the record (min double precision, max double precision)
     2397
     2398  nband: index of band
     2399
     2400  exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
     2401
     2402{{{
     2403ST_MinMax(rast, 1, FALSE)
     2404}}}
     2405
     24062. ST_MinMax(rast raster, nband int) -> record
     2407
     2408  assumes exclude_nodata_value = TRUE
     2409
     2410{{{
     2411ST_MinMax(rast, 2)
     2412}}}
     2413
     24143. ST_MinMax(rast raster, exclude_nodata_value boolean) -> record
     2415
     2416  assumes nband = 1
     2417
     2418{{{
     2419ST_MinMax(rast, TRUE)
     2420}}}
     2421
     24224. ST_MinMax(rast raster) -> record
     2423
     2424  assumes nband = 1 and exclude_nodata_value = TRUE
     2425
     2426{{{
     2427ST_MinMax(rast)
     2428}}}
     2429
     2430The set of ST_ApproxMinMax functions are:
     2431
     24321. ST_ApproxMinMax(rast raster, nband int, exclude_nodata_value boolean, sample_percent record) -> record
     2433
     2434  sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider
     2435
     2436{{{
     2437ST_ApproxMinMax(rast, 3, FALSE, 0.1)
     2438
     2439ST_ApproxMinMax(rast, 1, TRUE, 0.5)
     2440}}}
     2441
     24422. ST_ApproxMinMax(rast raster, nband int, sample_percent double precision) -> record
     2443
     2444  assumes that nband = 1
     2445
     2446{{{
     2447ST_ApproxMinMax(rast, 2 0.01)
     2448
     2449ST_ApproxMinMax(rast, 4, 0.025)
     2450}}}
     2451
     24523. ST_ApproxMinMax(rast raster, exclude_nodata_value boolean, sample_percent double precision) -> record
     2453
     2454  assumes that nband = 1
     2455
     2456{{{
     2457ST_ApproxMinMax(rast, FALSE, 0.01)
     2458
     2459ST_ApproxMinMax(rast, TRUE, 0.025)
     2460}}}
     2461
     24624. ST_ApproxMinMax(rast raster, sample_percent double precision) -> record
     2463
     2464  assumes that nband = 1 and exclude_nodata_value = TRUE
     2465
     2466{{{
     2467ST_ApproxMinMax(rast, 0.25)
     2468}}}
     2469
     24705. ST_ApproxMinMax(rast raster) -> record
     2471
     2472  assumes that nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2473
     2474{{{
     2475ST_ApproxMinMax(rast)
     2476}}}
     2477
     2478The following functions are provided for coverage tables.
     2479
     24801. ST_MinMax(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean) -> record
     2481
     2482  rastertable: name of table with raster column
     2483
     2484  rastercolumn: name of column of data type raster
     2485
     2486{{{
     2487ST_MinMax('tmax_2010', 'rast', 1, FALSE)
     2488
     2489ST_MinMax('precip_2011', 'rast', 1, TRUE)
     2490}}}
     2491
     24922. ST_MinMax(rastertable text, rastercolumn text, nband int) -> record
     2493
     2494    exclude_nodata_value = TRUE
     2495
     2496{{{
     2497ST_MinMax('tmax_2010', 'rast', 1)
     2498}}}
     2499
     25003. ST_MinMax(rastertable text, rastercolumn text, exclude_nodata_value boolean) -> record
     2501
     2502    nband = 1
     2503
     2504{{{
     2505ST_MinMax('precip_2011', 'rast', TRUE)
     2506}}}
     2507
     25084. ST_MinMax(rastertable text, rastercolumn text) -> record
     2509
     2510    nband = 1 and exclude_nodata_value = TRUE
     2511
     2512{{{
     2513ST_MinMax('tmin_2009', 'rast')
     2514}}}
     2515
     2516Variations for ST_ApproxMinMax are:
     2517
     25181. ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision) -> record
     2519
     2520{{{
     2521ST_ApproxMinMax('tmax_2010', 'rast', 1, FALSE, 0.5)
     2522
     2523ST_ApproxMinMax('precip_2011', 'rast', 1, TRUE, 0.2)
     2524}}}
     2525
     25262. ST_ApproxMinMax(rastertable text, rastercolumn text, nband int, sample_percent double precision) -> record
     2527
     2528    exclude_nodata_value = TRUE
     2529
     2530{{{
     2531ST_ApproxMinMax('tmax_2010', 'rast', 1, 0.5)
     2532
     2533ST_ApproxMinMax('precip_2011', 'rast', 1, 0.2)
     2534}}}
     2535
     25363. ST_ApproxMinMax(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision) -> record
     2537
     2538    nband = 1
     2539
     2540{{{
     2541ST_ApproxMinMax('tmax_2010', 'rast', FALSE, 0.5)
     2542
     2543ST_ApproxMinMax('precip_2011', 'rast', TRUE, 0.2)
     2544}}}
     2545
     25464. ST_ApproxMinMax(rastertable text, rastercolumn text, sample_percent double precision) -> record
     2547
     2548    nband = 1 and exclude_nodata_value = TRUE
     2549
     2550{{{
     2551ST_ApproxMinMax('tmax_2010', 'rast', 0.5)
     2552
     2553ST_ApproxMinMax('precip_2011', 'rast', 0.2)
     2554}}}
     2555
     25565. ST_ApproxMinMax(rastertable text, rastercolumn text) -> record
     2557
     2558    nband = 1, exclude_nodata_value = TRUE and sample_percent = 0.1
     2559
     2560{{{
     2561ST_ApproxMinMax('tmax_2010', 'rast')
     2562
     2563ST_ApproxMinMax('precip_2011', 'rast')
     2564}}}
     2565
     2566----
     2567
     2568'''ST_Histogram(raster, nband) -> set of records'''[[BR]]
     2569ST_Histogram and ST_ApproxHistogram provide methods to determine a raster's data distribution.
     2570
     2571The return of ST_Histogram and ST_ApproxHistogram is a set of records where each record is (min, max, count, percent).
     2572
     2573ST_Histogram has the following variations.
     2574
     25751. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, width double precision[], right boolean) -> set of records
     2576
     2577  returns set of records of four columns (min, max, count, percent)
     2578
     2579  nband: index of band to process on
     2580
     2581  exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
     2582
     2583  bins: the number of categories/bins to have in the histogram. If NULL or value less than one, the number of categories will be auto-computed using Sturges' formula if the number of values >= 30 or Square-root choice if number of values < 30.
     2584
     2585    http://en.wikipedia.org/wiki/Histogram#Mathematical_definition
     2586
     2587  width: an array indicating the width of each category/bin. If the number of bins is greater than the number of widths, the widths are repeated. Example: 9 bins, widths are [a, b, c] will have the output be [a, b, c, a, b, c, a, b, c].
     2588
     2589  right: compute the histogram from the right rather than from the left (default). This changes the criteria for evaluating a value x from [a, b) to (a, b].
     2590
     2591{{{
     2592ST_Histogram(rast, 2, FALSE, NULL, NULL, FALSE)
     2593
     2594ST_Histogram(rast, 1, TRUE, 100, NULL, FALSE)
     2595
     2596ST_Histogram(rast, 2, FALSE, NULL, ARRAY[100, 50], FALSE)
     2597
     2598ST_Histogram(rast, 2, FALSE, 9, ARRAY[1000], TRUE)
     2599
     2600ST_Histogram(rast, 2, FALSE, 20, ARRAY[100, 200, 300], TRUE)
     2601}}}
     2602
     26032. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, right boolean) -> set of records
     2604
     2605  parameter "width" is not specified thus resulting in all bins having the same widths
     2606
     2607{{{
     2608ST_Histogram(rast, 2, FALSE, 5, FALSE)
     2609}}}
     2610
     26113. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean, bins int) -> set of records
     2612
     2613  the parameter "right" is removed and assumed to be FALSE
     2614
     2615{{{
     2616ST_Histogram(rast, 2, FALSE, 5)
     2617}}}
     2618
     26194. ST_Histogram(rast raster, nband int, exclude_nodata_value boolean) -> set of records
     2620
     2621  the parameter "bins" is removed and set to NULL.  The function will compute the number of bins to use
     2622
     26235. ST_Histogram(rast raster, nband int) -> set of records
     2624
     2625  exclude_nodata_value is assumed to be TRUE
     2626
     26276. ST_Histogram(rast raster) -> set of records
     2628
     2629  assumes that nband is 1.
     2630
     26317. ST_Histogram(rast raster, nband int, bins int, width double precision[], right boolean) -> set of records
     2632
     2633  exclude_nodata_value is assumed to be TRUE
     2634
     26358. ST_Histogram(rast raster, nband int, bins int, right boolean) -> set of records
     2636
     2637  all bins will have equal widths
     2638
     26399. ST_Histogram(rast raster, nband int, bins int) -> set of records
     2640
     2641  right is assumed to be FALSE
     2642
     2643ST_ApproxHistogram should have the following variations.
     2644
     26451. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, width double precision[], right boolean) -> set of record
     2646
     2647    sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider when generating the histogram.
     2648
     2649{{{
     2650ST_Histogram(rast, 2, FALSE, 0.1, NULL, NULL, FALSE)
     2651
     2652ST_Histogram(rast, 1, TRUE, 1, 100, NULL, FALSE)
     2653
     2654ST_Histogram(rast, 2, FALSE, 0.2, NULL, ARRAY[100, 50], FALSE)
     2655
     2656ST_Histogram(rast, 2, FALSE, 0.25, 9, ARRAY[1000], TRUE)
     2657
     2658ST_Histogram(rast, 2, FALSE, 0.05, 20, ARRAY[100, 200, 300], TRUE)
     2659}}}
     2660
     26612. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean) -> set of records
     2662
     2663  parameter "width" is not specified thus resulting in all bins having the same widths
     2664
     26653. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int) -> set of records
     2666
     2667  the parameter "right" is removed and assumed to be FALSE
     2668
     2669{{{
     2670ST_ApproxHistogram(rast, 2, FALSE, 5)
     2671}}}
     2672
     26734. ST_ApproxHistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision) -> set of records
     2674
     2675  the parameter "bins" is removed and set to NULL so that function can compute the number of bins to use
     2676
     26775. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision) -> set of records
     2678
     2679  exclude_nodata_value is assumed to be TRUE
     2680
     26816. ST_ApproxHistogram(rast raster, nband int) -> set of records
     2682
     2683  assumes that sample_percent is 0.1
     2684
     26857. ST_ApproxHistogram(rast raster, sample_percent double_precision) -> set of records
     2686
     2687  assumes that nband is 1
     2688
     26898. ST_ApproxHistogram(rast raster) -> set of records
     2690
     2691  assumes that nband is 1 and sample_percent is 0.1
     2692
     26939. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int, width double precision[], right boolean) -> set of records
     2694
     2695  exclude_nodata_value is assumed to be TRUE
     2696
     269710. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int, right boolean) -> set of records
     2698
     2699  all bins will have equal widths
     2700
     270111. ST_ApproxHistogram(rast raster, nband int, sample_percent double precision, bins int) -> set of records
     2702
     2703  right is assumed to be FALSE
     2704
     2705The following set of function are for coverages.
     2706
     27071. ST_Histogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int default 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) -> set of records
     2708
     2709  rastertable: name of table with raster column
     2710
     2711  rastercolumn: name of column of data type raster
     2712
     2713{{{
     2714ST_Histogram('tmax_2010', 'rast')
     2715
     2716ST_Histogram('precip_2011', 'rast', 1)
     2717
     2718ST_Histogram('precip_2011', 'rast', 1, FALSE)
     2719
     2720ST_Histogram('precip_2011', 'rast', 1, FALSE, 5)
     2721
     2722ST_Histogram('precip_2011', 'rast', 1, FALSE, 10, NULL)
     2723
     2724ST_Histogram('precip_2011', 'rast', 1, FALSE, 10, NULL, TRUE)
     2725}}}
     2726
     27272. ST_Histogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, bins int, right boolean) -> set of records
     2728
     2729{{{
     2730ST_Histogram('tmin_2010', 'rast', 2, FALSE, 5, FALSE)
     2731}}}
     2732
     27333. ST_Histogram(rastertable text, rastercolumn text, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) -> set of records
     2734
     2735{{{
     2736ST_Histogram('ndvi_2010', 'rast', 1, 5)
     2737
     2738ST_Histogram('ndvi_2010', 'rast', 1, 0, ARRAY[0.5]::double precision[])
     2739
     2740ST_Histogram('ndvi_2010', 'rast', 1, 5, NULL, TRUE)
     2741}}}
     2742
     27434. ST_Histogram(rastertable text, rastercolumn text, nband int, bins int, right boolean) -> set of records
     2744
     2745{{{
     2746ST_Histogram('veg_2009', 'rast', 2, 3, FALSE)
     2747
     2748ST_Histogram('veg_2009', 'rast', 2, 3, TRUE)
     2749}}}
     2750
     2751A set of functions of ST_ApproxHistogram for coverage tables:
     2752
     27531. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE) -> set of records
     2754
     2755{{{
     2756ST_ApproxHistogram('precip_2010', 'rast')
     2757
     2758ST_ApproxHistogram('precip_2010', 'rast', 1)
     2759
     2760ST_ApproxHistogram('precip_2010', 'rast', 2, FALSE)
     2761
     2762ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.25)
     2763
     2764ST_ApproxHistogram('precip_2010', 'rast', 3, FALSE, 0.2, 10)
     2765
     2766ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.1, 0, ARRAY[1]::double precision[])
     2767
     2768ST_ApproxHistogram('precip_2010', 'rast', 1, TRUE, 0.1, 0, ARRAY[1]::double precision[], FALSE)
     2769}}}
     2770
     27712. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean)
     2772
     27733. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision)
     2774
     27754. ST_ApproxHistogram(rastertable text, rastercolumn text, sample_percent double precision)
     2776
     27775. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
     2778
     27796. ST_ApproxHistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, right boolean)
     2780
     2781----
     2782'''ST_Quantile(raster, nband) -> set of records'''[[BR]]
     2783In addition to determining the histogram of a raster, providing the ability to compute quantiles permits a user to reference a value in the context of the sample or population. Thus, a value could be examined to be at the raster's 25%, 50%, 75% percentile.
     2784
     2785http://en.wikipedia.org/wiki/Quantile
     2786
     2787ST_Quantile variations:
     2788
     27891. ST_Quantile(rast raster, nband int, exclude_nodata_value boolean, quantiles double precision[]) -> set of records
     2790
     2791  each row returned is of (quantile double precision, value double precision)
     2792
     2793  nband: index of band to process on
     2794
     2795  exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
     2796
     2797  quantiles: array of percentages to compute values for
     2798
     2799{{{
     2800ST_Quantile(rast, 1, FALSE, ARRAY[0.1, 0.3, 0.7])
     2801
     2802ST_Quantile(rast, 1, TRUE, ARRAY[0.2])
     2803
     2804ST_Quantile(rast, 1, FALSE, ARRAY[0, 1])
     2805}}}
     2806
     28072. ST_Quantile(rast raster, nband int, quantiles double precision[]) -> set of records
     2808
     2809  "exclude_nodata_value" is assumed to be TRUE
     2810
     2811{{{
     2812ST_Quantile(rast, 1, ARRAY[0.1, 0.3, 0.7])
     2813}}}
     2814
     28153. ST_Quantile(rast raster, nband int, exclude_nodata_value boolean) -> set of records
     2816
     2817  "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
     2818
     28194. ST_Quantile(rast raster, nband int) -> set of records
     2820
     2821  "exclude_nodata_value" is assumed to be TRUE and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
     2822
     28235. ST_Quantile(rast raster, quantiles double precision[]) -> set of records
     2824
     2825  "nband" is assumed to be 1 and "exclude_nodata_value" is TRUE
     2826
     28276. ST_Quantile(rast raster) -> set of records
     2828
     2829  "nband" is assumed to be 1 and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
     2830
     28317. ST_Quantile(rast raster, nband int, exclude_nodata_value boolean, quantile double precision) -> record
     2832
     2833  quantile: the single percentile to compute
     2834
     28358. ST_Quantile(rast raster, nband int, quantile double precision) -> record
     2836
     2837  "exclude_nodata_value" is assumed to be TRUE
     2838
     28399. ST_Quantile(rast raster, exclude_nodata_value boolean, quantile double precision) -> record
     2840
     2841  "nband" is assumed to be 1
     2842
     284310. ST_Quantile(rast raster, quantile double precision) -> record
     2844
     2845  "nband" is assumed to be 1  and "exclude_nodata_value" is assumed to be TRUE
     2846
     2847ST_ApproxQuantile adds a "sample_percent" indicating the percentage of the raster to sample
     2848
     28491. ST_ApproxQuantile(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, quantiles double precision[]) -> set of records
     2850
     2851  nband: index of band to process on
     2852
     2853  exclude_nodata_value: if FALSE, nodata values in band are included. if TRUE, nodata values are not included.
     2854
     2855  sample_percent: a value between 0 and 1 indicating the percentage of the raster band's pixels to consider when computing the quantiles
     2856
     2857  quantiles: array of percentages to compute values for
     2858
     2859{{{
     2860ST_ApproxQuantile(rast, 1, FALSE, 0.1, ARRAY[0.1, 0.3, 0.7])
     2861
     2862ST_ApproxQuantile(rast, 1, TRUE, .2, ARRAY[0.2])
     2863
     2864ST_ApproxQuantile(rast, 1, FALSE, 0.3, ARRAY[0, 1])
     2865}}}
     2866
     28672. ST_ApproxQuantile(rast raster, nband int, sample_percent double precision, quantiles double precision[]) -> set of records
     2868
     2869  "exclude_nodata_value" is assumed to be TRUE
     2870
     2871{{{
     2872ST_ApproxQuantile(rast, 1, .05, ARRAY[0.1, 0.3, 0.7])
     2873}}}
     2874
     28753. ST_ApproxQuantile(rast raster, nband int, sample_percent double precision) -> set of records
     2876
     2877  "exclude_nodata_value" is assumed to be TRUE and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
     2878
     28794. ST_ApproxQuantile(rast raster, sample_percent double precision, quantiles double precision[]) -> set of records
     2880
     2881  "nband" is assumed to be 1
     2882
     28835. ST_ApproxQuantile(rast raster, nband int, sample_percent double precision, quantile double precision) -> record
     2884
     2885  quantile: the single percentile to compute
     2886
     28876. ST_ApproxQuantile(rast raster, sample_percent double precision, quantile double precision) -> record
     2888
     2889  "nband" is assumed to be 2
     2890
     28917. ST_ApproxQuantile(rast raster, sample_percent double precision) -> set of records
     2892
     2893  "nband" is assumed to be 1 and "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1]
     2894
     28958. ST_ApproxQuantile(rast raster, nband int, quantile double precision) -> record
     2896
     2897  "sample_percent" assumed to be 0.1
     2898
     28999. ST_ApproxQuantile(rast raster, quantiles double precision[]) -> set of records
     2900
     2901  "nband" is assumed to be 1 and "sample_percent" assumed to be 0.1
     2902
     290310. ST_ApproxQuantile(rast raster, quantile double precision) -> record
     2904
     2905  "nband" assumed to be 1 and "sample_percent" assumed to be 0.1
     2906
     290711. ST_ApproxQuantile(rast raster, nband int) -> set of records
     2908
     2909  "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1] and "sample_percent" assumed to be 0.1
     2910
     291112. ST_ApproxQuantile(rast raster) -> set of records
     2912
     2913  "nband" is assumed to be 1, "quantiles" assumed to be ARRAY[0, 0.25, 0.5, 0.75, 1] and "sample_percent" assumed to be 0.1