872 | | '''ST_Count(raster, value) -> integer'''[[BR]] |
| 872 | |
| 873 | ---- |
| 874 | |
| 875 | '''ST_ValueCount(raster, value) -> integer'''[[BR]] |
| 876 | |
| 877 | 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. |
| 878 | |
| 879 | A set of functions for one or more search values: |
| 880 | |
| 881 | ''If NULL is passed for "searchvalues" to any of the ST_ValueCount variations with "searchvalues", the function returns the counts for all unique values'' |
| 882 | |
| 883 | 1. ST_ValueCount(rast raster, nband integer, hasnodata boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
| 884 | |
| 885 | returns the number of times that each value in searchvalues is present in the raster |
| 886 | |
| 887 | hasnodata: if FALSE, nodata values in band are considered in the count. if TRUE, nodata values are not considered |
| 888 | |
| 889 | searchvalues: the set of values to count in the raster |
| 890 | |
| 891 | 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. |
| 892 | |
| 893 | examples are... |
| 894 | |
| 895 | {{{ |
| 896 | roundto < 0: no rounding |
| 897 | |
| 898 | 0: no rounding |
| 899 | |
| 900 | 0.1: round to the tenths place |
| 901 | |
| 902 | 0.01: round to the hundredths place |
| 903 | |
| 904 | 0.001: round to the thousandths place |
| 905 | |
| 906 | 1: round to the ones place |
| 907 | |
| 908 | 10: round to the tens place |
| 909 | |
| 910 | 100: round to the hundreds place |
| 911 | }}} |
| 912 | |
| 913 | {{{ |
| 914 | ST_ValueCount(rast, 1, TRUE, ARRAY[23], 0) |
| 915 | |
| 916 | ST_ValueCount(rast, 5, FALSE, ARRAY[3.14], 0.01) |
| 917 | |
| 918 | ST_ValueCount(rast, 2, TRUE, ARRAY[100], 100) |
| 919 | |
| 920 | ST_ValueCount(rast, 1, FALSE, ARRAY[-9999, 0], 1) |
| 921 | |
| 922 | ST_ValueCount(rast, 1, FALSE, NULL::double precision[], 1) |
| 923 | }}} |
| 924 | |
| 925 | 2. ST_ValueCount(rast raster, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
| 926 | |
| 927 | hasnodata is assumed to be TRUE |
| 928 | |
| 929 | {{{ |
| 930 | ST_ValueCount(rast, 5, ARRAY[3.14], 0.01) |
| 931 | |
| 932 | ST_ValueCount(rast, 2, NULL::double precision[], 100) |
| 933 | }}} |
| 934 | |
| 935 | 3. ST_ValueCount(rast raster, nband integer, searchvalues double precision[]) -> setof record (searchvalue, count) |
| 936 | |
| 937 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 938 | |
| 939 | {{{ |
| 940 | ST_ValueCount(rast, 1, ARRAY[-9999]) |
| 941 | |
| 942 | ST_ValueCount(rast, 1, NULL::double precision[]) |
| 943 | }}} |
| 944 | |
| 945 | 4. ST_ValueCount(rast raster, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
| 946 | |
| 947 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 948 | |
| 949 | 5. ST_ValueCount(rast raster, searchvalues double precision[]) -> setof record (searchvalue, count) |
| 950 | |
| 951 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 952 | |
| 953 | A set of functions for a single search value: |
| 954 | |
| 955 | 1. ST_ValueCount(rast raster, nband integer, hasnodata boolean, searchvalue double precision, roundto double precision) -> integer |
| 956 | |
| 957 | returns the number of times that searchvalue is present in the raster |
| 958 | |
| 959 | searchvalue: the value to count in the raster |
| 960 | |
| 961 | {{{ |
| 962 | ST_ValueCount(rast, 1, TRUE, 23, 0) |
| 963 | |
| 964 | ST_ValueCount(rast, 5, FALSE, 3.14, 0.01) |
| 965 | |
| 966 | ST_ValueCount(rast, 2, TRUE, 100, 100) |
| 967 | |
| 968 | ST_ValueCount(rast, 1, FALSE, -9999, 1) |
| 969 | }}} |
| 970 | |
| 971 | 2. ST_ValueCount(rast raster, nband integer, searchvalue double precision, roundto double precision) -> integer |
| 972 | |
| 973 | hasnodata is assumed to be TRUE |
| 974 | |
| 975 | {{{ |
| 976 | ST_ValueCount(rast, 5, 3.14, 0.01) |
| 977 | |
| 978 | ST_ValueCount(rast, 2, 100, 100) |
| 979 | }}} |
| 980 | |
| 981 | 3. ST_ValueCount(rast raster, nband integer, searchvalue double precision) -> integer |
| 982 | |
| 983 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 984 | |
| 985 | {{{ |
| 986 | ST_ValueCount(rast, 1, -9999) |
| 987 | }}} |
| 988 | |
| 989 | 4. ST_ValueCount(rast raster, searchvalue double precision, roundto double precision) -> integer |
| 990 | |
| 991 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 992 | |
| 993 | 5. ST_ValueCount(rast raster, searchvalue double precision) -> integer |
| 994 | |
| 995 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 996 | |
| 997 | The set of functions for processing coverages return "bigint" instead of "integer". |
| 998 | |
| 999 | A set of functions for one or more search values: |
| 1000 | |
| 1001 | 1. ST_ValueCount(rastertable text, rastercolumn text, nband integer, hasnodata boolean, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
| 1002 | |
| 1003 | rastertable: name of the table with a raster column |
| 1004 | |
| 1005 | rastercolumn: name of the raster column |
| 1006 | |
| 1007 | {{{ |
| 1008 | ST_ValueCount('test', 'rast', 1, TRUE, ARRAY[23], 0) |
| 1009 | |
| 1010 | ST_ValueCount('test', 'rast', 5, FALSE, ARRAY[3.14], 0.01) |
| 1011 | |
| 1012 | ST_ValueCount('test', 'rast', 2, TRUE, ARRAY[100], 100) |
| 1013 | |
| 1014 | ST_ValueCount('test', 'rast', 1, FALSE, ARRAY[-9999, 0], 1) |
| 1015 | |
| 1016 | ST_ValueCount('test', 'rast', 1, FALSE, NULL::double precision[], 1) |
| 1017 | }}} |
| 1018 | |
| 1019 | 2. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
| 1020 | |
| 1021 | hasnodata is assumed to be TRUE |
| 1022 | |
| 1023 | {{{ |
| 1024 | ST_ValueCount('test', 'rast', 5, ARRAY[3.14], 0.01) |
| 1025 | |
| 1026 | ST_ValueCount('test', 'rast', 2, NULL::double precision[], 100) |
| 1027 | }}} |
| 1028 | |
| 1029 | 3. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[]) -> setof record (searchvalue, count) |
| 1030 | |
| 1031 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 1032 | |
| 1033 | {{{ |
| 1034 | ST_ValueCount('test', 'rast', 1, ARRAY[-9999]) |
| 1035 | |
| 1036 | ST_ValueCount('test', 'rast', 1, NULL::double precision[]) |
| 1037 | }}} |
| 1038 | |
| 1039 | 4. ST_ValueCount(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision) -> setof record (searchvalue, count) |
| 1040 | |
| 1041 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 1042 | |
| 1043 | 5. ST_ValueCount(rastertable text, rastercolumn text, searchvalues double precision[]) -> setof record (searchvalue, count) |
| 1044 | |
| 1045 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 1046 | |
| 1047 | A set of functions for a single search value: |
| 1048 | |
| 1049 | 1. ST_ValueCount(rastertable text, rastercolumn text, nband integer, hasnodata boolean, searchvalue double precision, roundto double precision) -> bigint |
| 1050 | |
| 1051 | returns the number of times that searchvalue is present in the raster |
| 1052 | |
| 1053 | searchvalue: the value to count in the raster |
| 1054 | |
| 1055 | {{{ |
| 1056 | ST_ValueCount('test', 'rast', 1, TRUE, 23, 0) |
| 1057 | |
| 1058 | ST_ValueCount('test', 'rast', 5, FALSE, 3.14, 0.01) |
| 1059 | |
| 1060 | ST_ValueCount('test', 'rast', 2, TRUE, 100, 100) |
| 1061 | |
| 1062 | ST_ValueCount('test', 'rast', 1, FALSE, -9999, 1) |
| 1063 | }}} |
| 1064 | |
| 1065 | 2. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision) -> bigint |
| 1066 | |
| 1067 | hasnodata is assumed to be TRUE |
| 1068 | |
| 1069 | {{{ |
| 1070 | ST_ValueCount('test', 'rast', 5, 3.14, 0.01) |
| 1071 | |
| 1072 | ST_ValueCount('test', 'rast', 2, 100, 100) |
| 1073 | }}} |
| 1074 | |
| 1075 | 3. ST_ValueCount(rastertable text, rastercolumn text, nband integer, searchvalue double precision) -> bigint |
| 1076 | |
| 1077 | roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE |
| 1078 | |
| 1079 | {{{ |
| 1080 | ST_ValueCount('test', 'rast', 1, -9999) |
| 1081 | }}} |
| 1082 | |
| 1083 | 4. ST_ValueCount(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision) -> bigint |
| 1084 | |
| 1085 | nband is assumed to be 1. hasnodata is assumed to be TRUE. |
| 1086 | |
| 1087 | 5. ST_ValueCount(rastertable text, rastercolumn text, searchvalue double precision) -> bigint |
| 1088 | |
| 1089 | nband is assumed to be 1. roundto is assumed to be 0, so no rounding takes place. hasnodata is assumed to be TRUE. |
| 1090 | |
| 1091 | ---- |