ST_CountAgg — 总计的。 返回一组栅格的给定波段中的像素数。 如果未指定 band,则默认为 band 1。如果 except_nodata_value 设置为 true,则仅计算不等于 NODATA 值的像素。
bigint ST_CountAgg(raster rast, integer nband, boolean exclude_nodata_value, double precision sample_percent);
bigint ST_CountAgg(raster rast, integer nband, boolean exclude_nodata_value);
bigint ST_CountAgg(raster rast, boolean exclude_nodata_value);
返回一组栅格的给定波段中的像素数。 如果未指定 band,则 nband 默认为 1。
如果 excex_nodata_value 设置为 true,则仅计算值不等于栅格 NODATA 值的像素。 将 except_nodata_value 设置为 false 以计算所有像素
默认情况下将对所有像素进行采样。 要获得更快的响应,请将sample_percent 设置为零 (0) 到一 (1) 之间的值
可用性:2.2.0
WITH foo AS (
SELECT
rast.rast
FROM (
SELECT ST_SetValue(
ST_SetValue(
ST_SetValue(
ST_AddBand(
ST_MakeEmptyRaster(10, 10, 10, 10, 2, 2, 0, 0,0)
, 1, '64BF', 0, 0
)
, 1, 1, 1, -10
)
, 1, 5, 4, 0
)
, 1, 5, 5, 3.14159
) AS rast
) AS rast
FULL JOIN (
SELECT generate_series(1, 10) AS id
) AS id
ON 1 = 1
)
SELECT
ST_CountAgg(rast, 1, TRUE)
FROM foo;
st_countagg
-------------
20
(1 row)