Search code examples
c#gdal

GDAL ReadRaster data array access orientation


I am using OSGeo.GDAL C# API version 3.6.3 to read elevation raster via the following code:

int xOff = 464917;
int yOff = 158902;
int width = 10;
int height = 10;
double[] buffer = new double[100];
Band bnd = Obj.GetRasterBand(1);
bnd.ReadRaster(xOff, yOff, width, height, buffer, width, height, 0, 0);

my question is to confirm the grid read in is as below, right?

enter image description here


Solution

  • Yes, you are right. You compute pixel offsets from the upper left corner for specific coordinates. Here is a GDAL C# Binding ReadRaster() Example.

    For efficient reading of big raster files, you may find this post useful. It mentions how to read a raster as blocks.