public void executeRegionGroup() { createOutRaster(); if (OutRaster == null) { Console.WriteLine("not all inputs specified"); return; } IWorkspaceEdit wksE = (IWorkspaceEdit)vWks; bool weEdit = true; if (wksE.IsBeingEdited()) { weEdit = false; } else { wksE.StartEditing(false); } wksE.StartEditOperation(); Console.WriteLine("Counter = " + counter.ToString()); int readclmsStep = PixelBlockWidth + 2; int readrwsStep = PixelBlockHeight + 2; IPnt outloc = new PntClass(); IPnt inloc = new PntClass(); try { for (int rp = 0; rp < rws; rp += PixelBlockHeight) //rws { for (int cp = 0; cp < clms; cp += PixelBlockWidth) //clms { Console.WriteLine("Write Raster location = " + cp.ToString() + ":" + rp.ToString()); Console.WriteLine("Read Raster location = " + (cp - 1).ToString() + ":" + (rp - 1).ToString()); outloc.SetCoords(cp, rp); inloc.SetCoords(cp - 1, rp - 1); middleRowColumn(outloc); } } IRaster2 rs2 = (IRaster2)OutRaster; IRasterDataset rsDset = rs2.RasterDataset; IRasterDatasetEdit2 rsDsetE = (IRasterDatasetEdit2)rsDset; rsDsetE.AlterAttributeTable(vatTable); wksE.StopEditOperation(); if (weEdit) { wksE.StopEditing(true); } } catch (Exception e) { Console.WriteLine(e.ToString()); } finally { } return; }
private void BuildRasterAttributeTable(IRasterDataset rasterDataset, ITable table) { //Cast to IRasterDatasetEdit2 to build a raster attribute table. IRasterDatasetEdit2 rasterDatasetEdit = (IRasterDatasetEdit2)rasterDataset; //Build a default raster attribute table with VALUE and COUNT fields. if (table == null) { rasterDatasetEdit.BuildAttributeTable(); } else { //Assign the given table as the raster attribute table. rasterDatasetEdit.AlterAttributeTable(table); } }