ST_ReclassExact — 创建一个新栅格,其波段通过对原始波段进行 1:1 映射重分类生成,将原波段中的值映射为目标波段中的新值。
raster ST_ReclassExact(
raster rast, double precision[] inputvalues, double precision[] outputvalues, integer bandnumber=1, text pixeltype=32BF, double precision nodatavalue=NULL)
;
根据 inputvalues
和 outputvalues
数组定义的重分类操作,生成一个新的栅格。输入栅格中与数组匹配的像元值将被映射为对应的值,所有未匹配的像元值将被映射为 nodatavalue
。
输出像元类型默认设为 float,但可通过 pixeltype
参数进行指定。若未指定 bandnumber
,则默认使用第 1 波段。
The new raster will have the same georeference, width, and height as the original raster. Bands not designated are returned unchanged.
可用性:3.6.0
创建一个小型栅格,并将其像元映射为新的值。
CREATE TABLE reclassexact ( id integer, rast raster ); -- -- Create a raster with just four pixels -- [1 2] -- [3 4] -- INSERT INTO reclassexact (id, rast) SELECT 1, ST_SetValues( ST_AddBand( ST_MakeEmptyRaster( 2, -- width in pixels 2, -- height in pixels 0, -- upper-left x-coordinate 0, -- upper-left y-coordinate 1, -- pixel size in x-direction -1, -- pixel size in y-direction (negative for north-up) 0, -- skew in x-direction 0, -- skew in y-direction 4326 -- SRID (e.g., WGS 84) ), '32BUI'::text, -- pixel type (e.g., '32BF' for float, '8BUI' for unsigned 8-bit int) 0.0, -- initial value for the band (e.g., 0.0 or a no-data value) -99 -- nodatavalue ), 1, -- band number (usually 1 for single-band rasters) 1, -- x origin for setting values (usually 1) 1, -- y origin for setting values (usually 1) ARRAY[ ARRAY[1, 2], ARRAY[3, 4] ]::double precision[][] -- 2D array of values ); -- Reclass the values to new values -- and dump the values of the new raster for display WITH rc AS ( SELECT ST_ReclassExact( rast, -- input raster ARRAY[4,3,2,1], -- input map ARRAY[14,13,12,11], -- output map 1, -- band number to remap '32BUI' -- output raster pixtype ) AS rast FROM reclassexact WHERE id = 1 ) SELECT 'rce-1', (ST_DumpValues(rc.rast)).* FROM rc;