ST_DumpValues — 获取指定波段的值作为二维数组。
setof record ST_DumpValues(
raster rast , integer[] nband=NULL , boolean exclude_nodata_value=true )
;
double precision[][] ST_DumpValues(
raster rast , integer nband , boolean exclude_nodata_value=true )
;
WITH foo AS ( SELECT ST_AddBand(ST_AddBand(ST_AddBand(ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI'::text, 1, 0), 2, '32BF'::text, 3, -9999), 3, '16BSI', 0, 0) AS rast ) SELECT (ST_DumpValues(rast)).* FROM foo; nband | valarray -------+------------------------------------------------------ 1 | {{1,1,1},{1,1,1},{1,1,1}} 2 | {{3,3,3},{3,3,3},{3,3,3}} 3 | {{NULL,NULL,NULL},{NULL,NULL,NULL},{NULL,NULL,NULL}} (3 rows)
WITH foo AS ( SELECT ST_AddBand(ST_AddBand(ST_AddBand(ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI'::text, 1, 0), 2, '32BF'::text, 3, -9999), 3, '16BSI', 0, 0) AS rast ) SELECT (ST_DumpValues(rast, ARRAY[3, 1])).* FROM foo; nband | valarray -------+------------------------------------------------------ 3 | {{NULL,NULL,NULL},{NULL,NULL,NULL},{NULL,NULL,NULL}} 1 | {{1,1,1},{1,1,1},{1,1,1}} (2 rows)
WITH foo AS ( SELECT ST_SetValue(ST_AddBand(ST_MakeEmptyRaster(3, 3, 0, 0, 1, -1, 0, 0, 0), 1, '8BUI', 1, 0), 1, 2, 5) AS rast ) SELECT (ST_DumpValues(rast, 1))[2][1] FROM foo; st_dumpvalues --------------- 5 (1 row)