[gdal-dev] The problem when using ReadRaster(C#) method
szekerest at gmail.com
Wed Aug 31 06:15:55 EDT 2011
You should make sure about the actual representation of the raster image,
whether it represents the pixel as floats as you have used float arrays in
the code. The last 2 parameters are used to define the byte offset of the
pixels and lines in the image ( for more info see the
Further C# related samples can be found here:
2011/8/31 hitweiran <hitweiran at sina.com>
> 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
> 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
> two parameters.
> Thanks a lot for your answer!
> View this message in context:
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the gdal-dev