名稱

ST_Count — 傳回柵格或柵格覆蓋中給定波段的像素數量。如果未指定波段,則預設為波段 1。如果 exclude_nodata_value 設定為 true,則僅計算不等於 nodata 值的像素。

概要

bigint ST_Count(raster rast, integer nband=1, boolean exclude_nodata_value=true);

bigint ST_Count(raster rast, boolean exclude_nodata_value);

描述

傳回柵格或柵格覆蓋中給定波段的像素數量。如果未指定波段,則 nband 預設為 1。

[Note]

如果 exclude_nodata_value 設定為 true,則僅計算值不等於柵格的 nodata 值的像素。將 exclude_nodata_value 設定為 false 以計算所有像素。

變更:3.1.0 - 移除 ST_Count(rastertable, rastercolumn, ...) 變體。請改用 ST_CountAgg

可用性:2.0.0

範例

--example will count all pixels not 249 and one will count all pixels.  --
SELECT rid, ST_Count(ST_SetBandNoDataValue(rast,249)) As exclude_nodata,
        ST_Count(ST_SetBandNoDataValue(rast,249),false) As include_nodata
    FROM dummy_rast WHERE rid=2;

rid | exclude_nodata | include_nodata
-----+----------------+----------------
   2 |             23 |             25