| 1086 | |
| 1087 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 1088 | |
| 1089 | ---- |
| 1090 | |
| 1091 | '''ST_ValuePercent(raster, value) -> double precision'''[[BR]] |
| 1092 | |
| 1093 | ST_ValuePercent is the sibling of ST_ValueCount and returns the percentage of a raster's band that is of a specified value. To handle floating point values, a rounding argument is provided. |
| 1094 | |
| 1095 | A set of functions for one or more search values: |
| 1096 | |
| 1097 | ''If NULL is passed for "searchvalues" to any of the ST_ValuePercent variations with "searchvalues", the function returns the percents for all unique values'' |
| 1098 | |
| 1099 | 1. ST_ValuePercent(rast raster, nband integer, hasnodata boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
| 1100 | |
| 1101 | returns the percentage of a raster's band that each value in searchvalues is found |
| 1102 | |
| 1103 | hasnodata: if FALSE, nodata values in band are considered in the percents. if TRUE, nodata values are not considered |
| 1104 | |
| 1105 | searchvalues: the set of values to get percents for in the raster |
| 1106 | |
| 1107 | roundto: the decimal position to round a pixel value to. Originally intended for use with 32BF and 64BF pixel types, it can also be used with integers when round to the tens, hundreds or higher place. |
| 1108 | |
| 1109 | examples are... |
| 1110 | |
| 1111 | {{{ |
| 1112 | roundto < 0: no rounding |
| 1113 | |
| 1114 | 0: no rounding |
| 1115 | |
| 1116 | 0.1: round to the tenths place |
| 1117 | |
| 1118 | 0.01: round to the hundredths place |
| 1119 | |
| 1120 | 0.001: round to the thousandths place |
| 1121 | |
| 1122 | 1: round to the ones place |
| 1123 | |
| 1124 | 10: round to the tens place |
| 1125 | |
| 1126 | 100: round to the hundreds place |
| 1127 | }}} |
| 1128 | |
| 1129 | {{{ |
| 1130 | ST_ValuePercent(rast, 1, TRUE, ARRAY[23], 0) |
| 1131 | |
| 1132 | ST_ValuePercent(rast, 5, FALSE, ARRAY[3.14], 0.01) |
| 1133 | |
| 1134 | ST_ValuePercent(rast, 2, TRUE, ARRAY[100], 100) |
| 1135 | |
| 1136 | ST_ValuePercent(rast, 1, FALSE, ARRAY[-9999, 0], 1) |
| 1137 | |
| 1138 | ST_ValuePercent(rast, 1, FALSE, NULL::double precision[], 1) |
| 1139 | }}} |
| 1140 | |
| 1141 | 2. ST_ValuePercent(rast raster, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
| 1142 | |
| 1143 | hasnodata is assumed to be TRUE |
| 1144 | |
| 1145 | {{{ |
| 1146 | ST_ValuePercent(rast, 5, ARRAY[3.14], 0.01) |
| 1147 | |
| 1148 | ST_ValuePercent(rast, 2, NULL::double precision[], 100) |
| 1149 | }}} |
| 1150 | |
| 1151 | 3. ST_ValuePercent(rast raster, nband integer, searchvalues double precision[]) -> setof record (searchvalue, percent) |
| 1152 | |
| 1153 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 1154 | |
| 1155 | {{{ |
| 1156 | ST_ValuePercent(rast, 1, ARRAY[-9999]) |
| 1157 | |
| 1158 | ST_ValuePercent(rast, 1, NULL::double precision[]) |
| 1159 | }}} |
| 1160 | |
| 1161 | 4. ST_ValuePercent(rast raster, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
| 1162 | |
| 1163 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 1164 | |
| 1165 | 5. ST_ValuePercent(rast raster, searchvalues double precision[]) -> setof record (searchvalue, percent) |
| 1166 | |
| 1167 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 1168 | |
| 1169 | A set of functions for a single search value: |
| 1170 | |
| 1171 | 1. ST_ValuePercent(rast raster, nband integer, hasnodata boolean, searchvalue double precision, roundto double precision) -> integer |
| 1172 | |
| 1173 | searchvalue: the value to get a percent for in the raster |
| 1174 | |
| 1175 | {{{ |
| 1176 | ST_ValuePercent(rast, 1, TRUE, 23, 0) |
| 1177 | |
| 1178 | ST_ValuePercent(rast, 5, FALSE, 3.14, 0.01) |
| 1179 | |
| 1180 | ST_ValuePercent(rast, 2, TRUE, 100, 100) |
| 1181 | |
| 1182 | ST_ValuePercent(rast, 1, FALSE, -9999, 1) |
| 1183 | }}} |
| 1184 | |
| 1185 | 2. ST_ValuePercent(rast raster, nband integer, searchvalue double precision, roundto double precision) -> integer |
| 1186 | |
| 1187 | hasnodata is assumed to be TRUE |
| 1188 | |
| 1189 | {{{ |
| 1190 | ST_ValuePercent(rast, 5, 3.14, 0.01) |
| 1191 | |
| 1192 | ST_ValuePercent(rast, 2, 100, 100) |
| 1193 | }}} |
| 1194 | |
| 1195 | 3. ST_ValuePercent(rast raster, nband integer, searchvalue double precision) -> integer |
| 1196 | |
| 1197 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 1198 | |
| 1199 | {{{ |
| 1200 | ST_ValuePercent(rast, 1, -9999) |
| 1201 | }}} |
| 1202 | |
| 1203 | 4. ST_ValuePercent(rast raster, searchvalue double precision, roundto double precision) -> integer |
| 1204 | |
| 1205 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 1206 | |
| 1207 | 5. ST_ValuePercent(rast raster, searchvalue double precision) -> integer |
| 1208 | |
| 1209 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 1210 | |
| 1211 | The set of functions for processing coverages return "bigint" instead of "integer". |
| 1212 | |
| 1213 | A set of functions for one or more search values: |
| 1214 | |
| 1215 | 1. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, hasnodata boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
| 1216 | |
| 1217 | rastertable: name of the table with a raster column |
| 1218 | |
| 1219 | rastercolumn: name of the raster column |
| 1220 | |
| 1221 | {{{ |
| 1222 | ST_ValuePercent('test', 'rast', 1, TRUE, ARRAY[23], 0) |
| 1223 | |
| 1224 | ST_ValuePercent('test', 'rast', 5, FALSE, ARRAY[3.14], 0.01) |
| 1225 | |
| 1226 | ST_ValuePercent('test', 'rast', 2, TRUE, ARRAY[100], 100) |
| 1227 | |
| 1228 | ST_ValuePercent('test', 'rast', 1, FALSE, ARRAY[-9999, 0], 1) |
| 1229 | |
| 1230 | ST_ValuePercent('test', 'rast', 1, FALSE, NULL::double precision[], 1) |
| 1231 | }}} |
| 1232 | |
| 1233 | 2. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
| 1234 | |
| 1235 | hasnodata is assumed to be TRUE |
| 1236 | |
| 1237 | {{{ |
| 1238 | ST_ValuePercent('test', 'rast', 5, ARRAY[3.14], 0.01) |
| 1239 | |
| 1240 | ST_ValuePercent('test', 'rast', 2, NULL::double precision[], 100) |
| 1241 | }}} |
| 1242 | |
| 1243 | 3. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[]) -> setof record (searchvalue, percent) |
| 1244 | |
| 1245 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 1246 | |
| 1247 | {{{ |
| 1248 | ST_ValuePercent('test', 'rast', 1, ARRAY[-9999]) |
| 1249 | |
| 1250 | ST_ValuePercent('test', 'rast', 1, NULL::double precision[]) |
| 1251 | }}} |
| 1252 | |
| 1253 | 4. ST_ValuePercent(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
| 1254 | |
| 1255 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 1256 | |
| 1257 | 5. ST_ValuePercent(rastertable text, rastercolumn text, searchvalues double precision[]) -> setof record (searchvalue, percent) |
| 1258 | |
| 1259 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 1260 | |
| 1261 | A set of functions for a single search value: |
| 1262 | |
| 1263 | 1. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, hasnodata boolean, searchvalue double precision, roundto double precision) -> bigint |
| 1264 | |
| 1265 | searchvalue: the value to get a percent for in the raster |
| 1266 | |
| 1267 | {{{ |
| 1268 | ST_ValuePercent('test', 'rast', 1, TRUE, 23, 0) |
| 1269 | |
| 1270 | ST_ValuePercent('test', 'rast', 5, FALSE, 3.14, 0.01) |
| 1271 | |
| 1272 | ST_ValuePercent('test', 'rast', 2, TRUE, 100, 100) |
| 1273 | |
| 1274 | ST_ValuePercent('test', 'rast', 1, FALSE, -9999, 1) |
| 1275 | }}} |
| 1276 | |
| 1277 | 2. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision) -> bigint |
| 1278 | |
| 1279 | hasnodata is assumed to be TRUE |
| 1280 | |
| 1281 | {{{ |
| 1282 | ST_ValuePercent('test', 'rast', 5, 3.14, 0.01) |
| 1283 | |
| 1284 | ST_ValuePercent('test', 'rast', 2, 100, 100) |
| 1285 | }}} |
| 1286 | |
| 1287 | 3. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision) -> bigint |
| 1288 | |
| 1289 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 1290 | |
| 1291 | {{{ |
| 1292 | ST_ValuePercent('test', 'rast', 1, -9999) |
| 1293 | }}} |
| 1294 | |
| 1295 | 4. ST_ValuePercent(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision) -> bigint |
| 1296 | |
| 1297 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 1298 | |
| 1299 | 5. ST_ValuePercent(rastertable text, rastercolumn text, searchvalue double precision) -> bigint |