private void GenerateMulitiGrid() { string filename = @"..\data\airport.grid"; GridFeatureLayer gridFeatureLayer = new GridFeatureLayer(filename); gridFeatureLayer.Open(); GridCell[,] allCells = gridFeatureLayer.GenerateGridMatrix(); RectangleShape extent = gridFeatureLayer.GetBoundingBox(); double cellSize = gridFeatureLayer.CellSize; int rows = allCells.GetLength(0); int cols = allCells.GetLength(1); int sectionNum = 4; int sectionX = sectionNum / 2; int sectionY = sectionNum / 2; int sectionRows = (rows % sectionY == 0) ? rows / sectionY : (rows / sectionY + 1); int sectionCols = (cols % sectionX == 0) ? cols / sectionX : (cols / sectionX + 1); int fileIndex = 0; for (int i = 0; i < sectionX; i++) { for (int j = 0; j < sectionY; j++) { PointShape ul = new PointShape(extent.UpperLeftPoint.X + i * sectionCols * cellSize, extent.UpperLeftPoint.Y - j * sectionRows * cellSize); PointShape lr = new PointShape(ul.X + sectionCols * cellSize, ul.Y - sectionRows * cellSize); if (i == (sectionX - 1)) { lr.X = extent.LowerRightPoint.X; } if (j == (sectionY - 1)) { lr.Y = extent.LowerRightPoint.Y; } RectangleShape currentSectionExtent = new RectangleShape(ul, lr); Dictionary currentDataPoints = new Dictionary(); for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { PointShape currentCell = new PointShape(allCells[row, col].CenterX, allCells[row, col].CenterY); if (currentCell.IsWithin(currentSectionExtent)) { currentDataPoints.Add(currentCell, allCells[row, col].Value); } } } GridDefinition definition = new GridDefinition(currentSectionExtent, gridFeatureLayer.CellSize, -9999, currentDataPoints); GridInterpolationModel interpolationModel = new InverseDistanceWeightedGridInterpolationModel(); string newFileName = @"..\data\newGrid" + fileIndex++ + ".grid"; FileStream outputStream = new FileStream(newFileName, FileMode.Create); GridFeatureSource.GenerateGrid(definition, interpolationModel, outputStream); } } }