ST_PixelData.setValue
Definition
The ST_PixelData.setValue function changes the value of a single pixel given that pixel's location within the ST_PixelData object and the new value. The location can be specified either in pixel coordinates or by geographic coordinates.
The function returns an error whenever the specified location is beyond the raster pixel dimension or geographic extent. ST_PixelData.setValue sets the pixel to NoData if the value is NULL.
Syntax
Oracle
setValue (band INTEGER, x INTEGER, y INTEGER, value NUMBER) setValue (band INTEGER, point SE_COORD, value NUMBER)
PostgreSQL
setValue (data IN ST_PixelData, band IN INT, x IN INT, y IN INT, value IN NUMBER) setValue (data IN ST_PixelData, band IN INT, point IN SE_COORD, value IN NUMBER)
SQL Server
setValue (band IN INTEGER, x IN INTEGER, y IN INTEGER, value IN NUMBER) setValueByLoc (band IN INTEGER, x IN DOUBLE, y IN DOUBLE, value IN NUMBER)
Returns
None
Parameters
Parameter | Description |
---|---|
data | Denotes the ST_PixelData object to be modified |
band | The band number (beginning at 1) of the pixel |
x | The x-pixel coordinate |
y | The y-pixel coordinate |
point | The geographic coordinate of the pixel |
value | The pixel value; must fall within the allowable range specified by the pixel depth of the ST_PixelData type |
Examples
The following sets the value of a single pixel given that pixel's location within the ST_PixelData object.
Oracle
DECLARE p sde.ST_PixelData := sde.ST_PixelData(256, 256, 1, 'pixelType=uint8'); BEGIN p.setValue(1, 0, 0, 100); p.setValue(1, 0, 1, 101); p.setExtent(SE_EXTENT(0,0,20,20)); INSERT INTO FOO VALUES (p); END;
PostgreSQL
CREATE OR REPLACE FUNCTION set_pixel_value() RETURNS integer AS ' DECLARE p sde.ST_PIXELDATA := st_pixeldata(256, 256, 1, ''pixelType=uint8''); BEGIN setValue(p, 1, 0, 0, 100); setValue(p, 1, 0, 1, 101); setExtent(p, SDE.SE_EXTENT(0,0,20,20)); INSERT INTO foo VALUES (ST_RASTER(p)); END; ' LANGUAGE plpgsql; SELECT set_pixel_data(); DROP FUNCTION IF EXISTS set_pixel_data();
SQL Server
DECLARE @p ST_Pixeldata; SET @p = ST_Pixeldata::construct(256, 256, 1, 'pixelType=uint8'); SELECT @p = @p.setValue(1, 0, 0, 100); SELECT @p = @p.setValue(1, 0, 1, 101); SELECT @p = @p.setExtent(0,0,20,20); INSERT INTO foo VALUES (ST_Raster::construct(NULL,@p,NULL));