Name

ST_SetValue — 返回因设置给定列x、行像素或与特定几何图形相交的像素中的给定波段的值而修改的栅格。波段编号从1开始,如果未指定,则假定为1。

Synopsis

raster ST_SetValue(raster rast, integer bandnum, geometry geom, double precision newvalue);

raster ST_SetValue(raster rast, geometry geom, double precision newvalue);

raster ST_SetValue(raster rast, integer bandnum, integer columnx, integer rowy, double precision newvalue);

raster ST_SetValue(raster rast, integer columnx, integer rowy, double precision newvalue);

描述

返回修改后的栅格,其结果是在给定栅格的行和列或几何图形的情况下,将指定带区的指定像素值设置为新值。如果未指定波段,则假定为波段1。

增强:ST_SetValue()的2.1.0几何体变体现在支持任何几何体类型,而不仅仅是点。几何变量是ST_SetValues()的geomval[]变量的包装器

示例

-- Geometry example
SELECT (foo.geomval).val, ST_AsText(ST_Union((foo.geomval).geom))
FROM (SELECT ST_DumpAsPolygons(
        ST_SetValue(rast,1,
                ST_Point(3427927.75, 5793243.95),
                50)
            ) As geomval
FROM dummy_rast
where rid = 2) As foo
WHERE (foo.geomval).val < 250
GROUP BY (foo.geomval).val;

 val |                                                     st_astext
-----+-------------------------------------------------------------------
  50 | POLYGON((3427927.75 5793244,3427927.75 5793243.95,3427927.8 579324 ...
 249 | POLYGON((3427927.95 5793243.95,3427927.95 5793243.85,3427928 57932 ...

                
-- Store the changed raster --
    UPDATE dummy_rast SET rast = ST_SetValue(rast,1, ST_Point(3427927.75, 5793243.95),100)
        WHERE rid = 2   ;

                

另请参阅

ST_Value, ST_DumpAsPolygons