Incorrect values in a raster

134
1
12-07-2017 12:47 PM
Highlighted
New Contributor

Hello, I'm trying to save data as a raster. Right before editing a raster I save the result to CSV and plot it with python to compare results, see python_result.PNG. Since I cannot create raster dataset from scratch I save the orginal source raster and insert the values in. Then I save it again. The problem is the raster doesn't look anything like they should. First and second saved raster are not even identical. (See images.)

Any idea where the problem could be?

Thank you

Code:

RasterStorageDef rasterStorageDef = new RasterStorageDef();
rasterStorageDef.SetPyramidLevel(0);
RasterDataset finalRaster = raster.SaveAs("FirstRaster.tiff", outputDataStore, rasterFormat, rasterStorageDef);

Raster resultRaster = finalRaster.CreateRaster(new int[1] { 0 });
resultRaster.SetNoDataValue(0);
resultRaster.SetPixelType(RasterPixelType.DOUBLE);
if (resultRaster.CanEdit()) {
   MessageBox.Show("Cannot edit raster");
   return;
}

currentPixelBlock.Clear(0);
resultRaster.Write(0, 0, currentPixelBlock);

PixelBlock newPixelBlock = resultRaster.CreatePixelBlock(resultRaster.GetWidth(), resultRaster.GetHeight());
newPixelBlock.SetPixelData(0, result.Transpose());
resultRaster.Write(0, 0, newPixelBlock);
resultRaster.Refresh();

resultRaster.SaveAs("SecondRaster.tiff", outputDataStore, rasterFormat, rasterStorageDef);
Reply
0 Kudos
1 Reply
Highlighted
Esri Contributor

Based on the provided code snippets it is hard to tell why you are seeing the results. We would need to take a look at what the Python code does and compare it to the Pro code. The usage of currentPixelBlock and result is pretty much undefined based on the given information.

Reply
0 Kudos