AnsweredAssumed Answered

Edit raster pixel by pixel

Question asked by maxmaxmaxmaxmax on Jun 9, 2019
Latest reply on Jun 20, 2019 by maxmaxmaxmaxmax

I'm trying to edit raster of GDB raster dataset added to map as RasterLayer. I need to set new extent, height, width and cells values. My code is:


var raster = layer.GetRaster();


var pixelBlockHeight = Math.Min(raster.GetHeight(), rowsCount);
var pixelBlockWidth = Math.Min(raster.GetWidth(), columnsCount);
var pixelBlock = raster.CreatePixelBlock(pixelBlockWidth, pixelBlockHeight);

raster.Read(0, 0, pixelBlock);
var sourcePixels = pixelBlock.GetPixelData(0, false);

for (var i = 0; i < pixelBlockHeight; i++)
    for (var j = 0; j < pixelBlockWidth; j++)
        sourcePixels.SetValue(Convert.ToUInt32(1000), j, i);

pixelBlock.SetPixelData(0, sourcePixels);

raster.Write(0, 0, pixelBlock);

But nothing happens. No values are applied. If I get pixel block again, all values are zero. Statistics is empty.


What am I doing wrong?