[gdal-dev] The problem when using ReadRaster(C#) method

hitweiran hitweiran at sina.com
Wed Aug 31 05:49:04 EDT 2011

I want to read a multiband image(in format of .img) by using method
ReadRaster, however, I encount some problems. I just can't understand why
the data loaded to memory is wrong?
the code is like this

OSGeo.GDAL.Dataset dataSet =
int width = dataSet.RasterXSize;
int height = dataSet.RasterYSize;
int Band_Numbers = dataSet.RasterCount;
float [] buffer_first = new float [width * height];
OSGeo.GDAL.Band One_Band = dataSet.GetRasterBand(1);
One_Band.ReadRaster(0, 0, width, height,buffer_first, width, height, 0,0);

However, the output is wrong!
I watch the variable "buffer_first" in watch window, and discoverse that the
data is quite terrible-some data is such as 2.818478E+21,5.065476E+32, or
-6.131138E-11 and so on;
So I suspect my datatype is mismatch to data in img file, or the last two
arguments in ReadRaster is mistake, because I don't know the meaning of last
two parameters.
Thanks a lot for your answer!  

View this message in context: http://osgeo-org.1803224.n2.nabble.com/The-problem-when-using-ReadRaster-C-method-tp6745826p6745826.html
Sent from the GDAL - Dev mailing list archive at Nabble.com.

More information about the gdal-dev mailing list