204 | | ---- |
205 | | |
206 | | '''ST_ValueCount(raster, value) -> integer'''[[BR]] |
207 | | |
208 | | ST_ValueCount provides the ability to count the number of times that a user-provided value is present in a raster. To handle floating point values, a rounding argument is provided. |
209 | | |
210 | | A set of functions for one or more search values: |
211 | | |
212 | | ''If NULL is passed for "searchvalues" to any of the ST_ValueCount variations with "searchvalues", the function returns the counts for all unique values'' |
213 | | |
214 | | 1. ST_ValueCount(rast raster, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
215 | | |
216 | | returns the number of times that each value in searchvalues is present in the raster |
217 | | |
218 | | exclude_nodata_value: if FALSE, nodata values in band are considered in the count. if TRUE, nodata values are not considered |
219 | | |
220 | | searchvalues: the set of values to count in the raster |
221 | | |
222 | | 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. |
223 | | |
224 | | examples are... |
225 | | |
226 | | {{{ |
227 | | roundto < 0: no rounding |
228 | | |
229 | | 0: no rounding |
230 | | |
231 | | 0.1: round to the tenths place |
232 | | |
233 | | 0.01: round to the hundredths place |
234 | | |
235 | | 0.001: round to the thousandths place |
236 | | |
237 | | 1: round to the ones place |
238 | | |
239 | | 10: round to the tens place |
240 | | |
241 | | 100: round to the hundreds place |
242 | | }}} |
243 | | |
244 | | {{{ |
245 | | ST_ValueCount(rast, 1, TRUE, ARRAY[23], 0) |
246 | | |
247 | | ST_ValueCount(rast, 5, FALSE, ARRAY[3.14], 0.01) |
248 | | |
249 | | ST_ValueCount(rast, 2, TRUE, ARRAY[100], 100) |
250 | | |
251 | | ST_ValueCount(rast, 1, FALSE, ARRAY[-9999, 0], 1) |
252 | | |
253 | | ST_ValueCount(rast, 1, FALSE, NULL::double precision[], 1) |
254 | | }}} |
255 | | |
256 | | 2. ST_ValueCount(rast raster, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
257 | | |
258 | | exclude_nodata_value is assumed to be TRUE |
259 | | |
260 | | {{{ |
261 | | ST_ValueCount(rast, 5, ARRAY[3.14], 0.01) |
262 | | |
263 | | ST_ValueCount(rast, 2, NULL::double precision[], 100) |
264 | | }}} |
265 | | |
266 | | 3. ST_ValueCount(rast raster, nband integer, searchvalues double precision[]) -> setof record (searchvalue, count) |
267 | | |
268 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
269 | | |
270 | | {{{ |
271 | | ST_ValueCount(rast, 1, ARRAY[-9999]) |
272 | | |
273 | | ST_ValueCount(rast, 1, NULL::double precision[]) |
274 | | }}} |
275 | | |
276 | | 4. ST_ValueCount(rast raster, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
277 | | |
278 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
279 | | |
280 | | 5. ST_ValueCount(rast raster, searchvalues double precision[]) -> setof record (searchvalue, count) |
281 | | |
282 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
283 | | |
284 | | A set of functions for a single search value: |
285 | | |
286 | | 1. ST_ValueCount(rast raster, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) -> integer |
287 | | |
288 | | returns the number of times that searchvalue is present in the raster |
289 | | |
290 | | searchvalue: the value to count in the raster |
291 | | |
292 | | {{{ |
293 | | ST_ValueCount(rast, 1, TRUE, 23, 0) |
294 | | |
295 | | ST_ValueCount(rast, 5, FALSE, 3.14, 0.01) |
296 | | |
297 | | ST_ValueCount(rast, 2, TRUE, 100, 100) |
298 | | |
299 | | ST_ValueCount(rast, 1, FALSE, -9999, 1) |
300 | | }}} |
301 | | |
302 | | 2. ST_ValueCount(rast raster, nband integer, searchvalue double precision, roundto double precision) -> integer |
303 | | |
304 | | exclude_nodata_value is assumed to be TRUE |
305 | | |
306 | | {{{ |
307 | | ST_ValueCount(rast, 5, 3.14, 0.01) |
308 | | |
309 | | ST_ValueCount(rast, 2, 100, 100) |
310 | | }}} |
311 | | |
312 | | 3. ST_ValueCount(rast raster, nband integer, searchvalue double precision) -> integer |
313 | | |
314 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
315 | | |
316 | | {{{ |
317 | | ST_ValueCount(rast, 1, -9999) |
318 | | }}} |
319 | | |
320 | | 4. ST_ValueCount(rast raster, searchvalue double precision, roundto double precision) -> integer |
321 | | |
322 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
323 | | |
324 | | 5. ST_ValueCount(rast raster, searchvalue double precision) -> integer |
325 | | |
326 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
327 | | |
328 | | The set of functions for processing coverages return "bigint" instead of "integer". |
329 | | |
330 | | A set of functions for one or more search values: |
331 | | |
332 | | 1. ST_ValueCount(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
333 | | |
334 | | rastertable: name of the table with a raster column |
335 | | |
336 | | rastercolumn: name of the raster column |
337 | | |
338 | | {{{ |
339 | | ST_ValueCount('test', 'rast', 1, TRUE, ARRAY[23], 0) |
340 | | |
341 | | ST_ValueCount('test', 'rast', 5, FALSE, ARRAY[3.14], 0.01) |
342 | | |
343 | | ST_ValueCount('test', 'rast', 2, TRUE, ARRAY[100], 100) |
344 | | |
345 | | ST_ValueCount('test', 'rast', 1, FALSE, ARRAY[-9999, 0], 1) |
346 | | |
347 | | ST_ValueCount('test', 'rast', 1, FALSE, NULL::double precision[], 1) |
348 | | }}} |
349 | | |
350 | | 2. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
351 | | |
352 | | exclude_nodata_value is assumed to be TRUE |
353 | | |
354 | | {{{ |
355 | | ST_ValueCount('test', 'rast', 5, ARRAY[3.14], 0.01) |
356 | | |
357 | | ST_ValueCount('test', 'rast', 2, NULL::double precision[], 100) |
358 | | }}} |
359 | | |
360 | | 3. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[]) -> setof record (searchvalue, count) |
361 | | |
362 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
363 | | |
364 | | {{{ |
365 | | ST_ValueCount('test', 'rast', 1, ARRAY[-9999]) |
366 | | |
367 | | ST_ValueCount('test', 'rast', 1, NULL::double precision[]) |
368 | | }}} |
369 | | |
370 | | 4. ST_ValueCount(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
371 | | |
372 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
373 | | |
374 | | 5. ST_ValueCount(rastertable text, rastercolumn text, searchvalues double precision[]) -> setof record (searchvalue, count) |
375 | | |
376 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
377 | | |
378 | | A set of functions for a single search value: |
379 | | |
380 | | 1. ST_ValueCount(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) -> bigint |
381 | | |
382 | | searchvalue: the value to count in the raster |
383 | | |
384 | | {{{ |
385 | | ST_ValueCount('test', 'rast', 1, TRUE, 23, 0) |
386 | | |
387 | | ST_ValueCount('test', 'rast', 5, FALSE, 3.14, 0.01) |
388 | | |
389 | | ST_ValueCount('test', 'rast', 2, TRUE, 100, 100) |
390 | | |
391 | | ST_ValueCount('test', 'rast', 1, FALSE, -9999, 1) |
392 | | }}} |
393 | | |
394 | | 2. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision) -> bigint |
395 | | |
396 | | exclude_nodata_value is assumed to be TRUE |
397 | | |
398 | | {{{ |
399 | | ST_ValueCount('test', 'rast', 5, 3.14, 0.01) |
400 | | |
401 | | ST_ValueCount('test', 'rast', 2, 100, 100) |
402 | | }}} |
403 | | |
404 | | 3. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalue double precision) -> bigint |
405 | | |
406 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
407 | | |
408 | | {{{ |
409 | | ST_ValueCount('test', 'rast', 1, -9999) |
410 | | }}} |
411 | | |
412 | | 4. ST_ValueCount(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision) -> bigint |
413 | | |
414 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
415 | | |
416 | | 5. ST_ValueCount(rastertable text, rastercolumn text, searchvalue double precision) -> bigint |
417 | | |
418 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
419 | | |
420 | | ---- |
421 | | |
422 | | '''ST_ValuePercent(raster, value) -> double precision'''[[BR]] |
423 | | |
424 | | 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. |
425 | | |
426 | | A set of functions for one or more search values: |
427 | | |
428 | | ''If NULL is passed for "searchvalues" to any of the ST_ValuePercent variations with "searchvalues", the function returns the percents for all unique values'' |
429 | | |
430 | | 1. ST_ValuePercent(rast raster, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
431 | | |
432 | | returns the percentage of a raster's band that each value in searchvalues is found |
433 | | |
434 | | exclude_nodata_value: if FALSE, nodata values in band are considered in the percents. if TRUE, nodata values are not considered |
435 | | |
436 | | searchvalues: the set of values to get percents for in the raster |
437 | | |
438 | | 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. |
439 | | |
440 | | examples are... |
441 | | |
442 | | {{{ |
443 | | roundto < 0: no rounding |
444 | | |
445 | | 0: no rounding |
446 | | |
447 | | 0.1: round to the tenths place |
448 | | |
449 | | 0.01: round to the hundredths place |
450 | | |
451 | | 0.001: round to the thousandths place |
452 | | |
453 | | 1: round to the ones place |
454 | | |
455 | | 10: round to the tens place |
456 | | |
457 | | 100: round to the hundreds place |
458 | | }}} |
459 | | |
460 | | {{{ |
461 | | ST_ValuePercent(rast, 1, TRUE, ARRAY[23], 0) |
462 | | |
463 | | ST_ValuePercent(rast, 5, FALSE, ARRAY[3.14], 0.01) |
464 | | |
465 | | ST_ValuePercent(rast, 2, TRUE, ARRAY[100], 100) |
466 | | |
467 | | ST_ValuePercent(rast, 1, FALSE, ARRAY[-9999, 0], 1) |
468 | | |
469 | | ST_ValuePercent(rast, 1, FALSE, NULL::double precision[], 1) |
470 | | }}} |
471 | | |
472 | | 2. ST_ValuePercent(rast raster, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
473 | | |
474 | | exclude_nodata_value is assumed to be TRUE |
475 | | |
476 | | {{{ |
477 | | ST_ValuePercent(rast, 5, ARRAY[3.14], 0.01) |
478 | | |
479 | | ST_ValuePercent(rast, 2, NULL::double precision[], 100) |
480 | | }}} |
481 | | |
482 | | 3. ST_ValuePercent(rast raster, nband integer, searchvalues double precision[]) -> setof record (searchvalue, percent) |
483 | | |
484 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
485 | | |
486 | | {{{ |
487 | | ST_ValuePercent(rast, 1, ARRAY[-9999]) |
488 | | |
489 | | ST_ValuePercent(rast, 1, NULL::double precision[]) |
490 | | }}} |
491 | | |
492 | | 4. ST_ValuePercent(rast raster, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
493 | | |
494 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
495 | | |
496 | | 5. ST_ValuePercent(rast raster, searchvalues double precision[]) -> setof record (searchvalue, percent) |
497 | | |
498 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
499 | | |
500 | | A set of functions for a single search value: |
501 | | |
502 | | 1. ST_ValuePercent(rast raster, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) -> integer |
503 | | |
504 | | searchvalue: the value to get a percent for in the raster |
505 | | |
506 | | {{{ |
507 | | ST_ValuePercent(rast, 1, TRUE, 23, 0) |
508 | | |
509 | | ST_ValuePercent(rast, 5, FALSE, 3.14, 0.01) |
510 | | |
511 | | ST_ValuePercent(rast, 2, TRUE, 100, 100) |
512 | | |
513 | | ST_ValuePercent(rast, 1, FALSE, -9999, 1) |
514 | | }}} |
515 | | |
516 | | 2. ST_ValuePercent(rast raster, nband integer, searchvalue double precision, roundto double precision) -> integer |
517 | | |
518 | | exclude_nodata_value is assumed to be TRUE |
519 | | |
520 | | {{{ |
521 | | ST_ValuePercent(rast, 5, 3.14, 0.01) |
522 | | |
523 | | ST_ValuePercent(rast, 2, 100, 100) |
524 | | }}} |
525 | | |
526 | | 3. ST_ValuePercent(rast raster, nband integer, searchvalue double precision) -> integer |
527 | | |
528 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
529 | | |
530 | | {{{ |
531 | | ST_ValuePercent(rast, 1, -9999) |
532 | | }}} |
533 | | |
534 | | 4. ST_ValuePercent(rast raster, searchvalue double precision, roundto double precision) -> integer |
535 | | |
536 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
537 | | |
538 | | 5. ST_ValuePercent(rast raster, searchvalue double precision) -> integer |
539 | | |
540 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
541 | | |
542 | | The set of functions for processing coverages return "bigint" instead of "integer". |
543 | | |
544 | | A set of functions for one or more search values: |
545 | | |
546 | | 1. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
547 | | |
548 | | rastertable: name of the table with a raster column |
549 | | |
550 | | rastercolumn: name of the raster column |
551 | | |
552 | | {{{ |
553 | | ST_ValuePercent('test', 'rast', 1, TRUE, ARRAY[23], 0) |
554 | | |
555 | | ST_ValuePercent('test', 'rast', 5, FALSE, ARRAY[3.14], 0.01) |
556 | | |
557 | | ST_ValuePercent('test', 'rast', 2, TRUE, ARRAY[100], 100) |
558 | | |
559 | | ST_ValuePercent('test', 'rast', 1, FALSE, ARRAY[-9999, 0], 1) |
560 | | |
561 | | ST_ValuePercent('test', 'rast', 1, FALSE, NULL::double precision[], 1) |
562 | | }}} |
563 | | |
564 | | 2. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
565 | | |
566 | | exclude_nodata_value is assumed to be TRUE |
567 | | |
568 | | {{{ |
569 | | ST_ValuePercent('test', 'rast', 5, ARRAY[3.14], 0.01) |
570 | | |
571 | | ST_ValuePercent('test', 'rast', 2, NULL::double precision[], 100) |
572 | | }}} |
573 | | |
574 | | 3. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[]) -> setof record (searchvalue, percent) |
575 | | |
576 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
577 | | |
578 | | {{{ |
579 | | ST_ValuePercent('test', 'rast', 1, ARRAY[-9999]) |
580 | | |
581 | | ST_ValuePercent('test', 'rast', 1, NULL::double precision[]) |
582 | | }}} |
583 | | |
584 | | 4. ST_ValuePercent(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, percent) |
585 | | |
586 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
587 | | |
588 | | 5. ST_ValuePercent(rastertable text, rastercolumn text, searchvalues double precision[]) -> setof record (searchvalue, percent) |
589 | | |
590 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |
591 | | |
592 | | A set of functions for a single search value: |
593 | | |
594 | | 1. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision) -> bigint |
595 | | |
596 | | searchvalue: the value to get a percent for in the raster |
597 | | |
598 | | {{{ |
599 | | ST_ValuePercent('test', 'rast', 1, TRUE, 23, 0) |
600 | | |
601 | | ST_ValuePercent('test', 'rast', 5, FALSE, 3.14, 0.01) |
602 | | |
603 | | ST_ValuePercent('test', 'rast', 2, TRUE, 100, 100) |
604 | | |
605 | | ST_ValuePercent('test', 'rast', 1, FALSE, -9999, 1) |
606 | | }}} |
607 | | |
608 | | 2. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision) -> bigint |
609 | | |
610 | | exclude_nodata_value is assumed to be TRUE |
611 | | |
612 | | {{{ |
613 | | ST_ValuePercent('test', 'rast', 5, 3.14, 0.01) |
614 | | |
615 | | ST_ValuePercent('test', 'rast', 2, 100, 100) |
616 | | }}} |
617 | | |
618 | | 3. ST_ValuePercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision) -> bigint |
619 | | |
620 | | roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE |
621 | | |
622 | | {{{ |
623 | | ST_ValuePercent('test', 'rast', 1, -9999) |
624 | | }}} |
625 | | |
626 | | 4. ST_ValuePercent(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision) -> bigint |
627 | | |
628 | | nband is assumed to be 1. exclude_nodata_value is assumed to be TRUE. |
629 | | |
630 | | 5. ST_ValuePercent(rastertable text, rastercolumn text, searchvalue double precision) -> bigint |
631 | | |
632 | | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. exclude_nodata_value is assumed to be TRUE. |