ST_ReclassExact — Creates a new raster composed of bands reclassified from original, using a 1:1 mapping from values in the original band to new values in the destination band.
raster ST_ReclassExact(
raster rast, double precision[] inputvalues, double precision[] outputvalues, integer bandnumber=1, text pixeltype=32BF, double precision nodatavalue=NULL)
;
Creates a new raster formed by applying a reclassification operation defined by the inputvalues
and outputvalues
arrays. Pixel values found in the input array are mapped to the corresponding value in the output array. All other pixel values are mapped to the nodatavalue
.
The output pixel type defaults to float, but can be specified using the pixeltype
parameter. If no bandnumber
is specified band 1 is assumed.
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 a small raster and map its pixels to new values.
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;