Hi,
I have a GridFeatureLayer where the internal projection is lat/long and I’m displaying it in a projected map. The projection looks just fine, but when I try and query the GridCell[,] array, I am returning incorrect values of Z.
Here’s the code I’ve always used based on one of the samples. To be honest, this code looks like it would only work on projected data. But, since GridCell[,] is a 2D array and gfl.CellSize is static I am not sure how one could make this work on a lat/long grid.
Please let me know if it is possible to get the correct Z value.
gfl.Open();
_cells = gfl.GenerateGridMatrix();
_gridRect = gfl.GetBoundingBox();
gfl.Close();
double cellSize = gfl.CellSize;
int binX = Convert.ToInt32((WorldPointR.X - _gridRect.UpperLeftPoint.X) / cellSize);
int binY = Convert.ToInt32((_gridRect.UpperLeftPoint.Y - WorldPointR.Y) / cellSize);
double z = _cells[binY, binX].Value;
Regards,
Damian