Re: [gdal-dev] [GDAL dev][GDALRasterBand::IReadBlock] About how to read all the raster bands.
Lucena, Ivan
ivan.lucena at pmldnet.com
Fri Oct 10 08:13:55 EDT 2008
Hi There,
I am not quite sure that I understood your problem, but I am pretty sure that you can write whatever bock size you
want. On the "GDAL implementation tutorial" [1] you should that especial attention to fill up those attributes:
GDALDataset::nRasterXSize
GDALDataset::nRasterYSize
GDALRasterBand::nBlockYSize
GDALRasterBand::nBlockXSize
GDALRasterBand::eDataType
That will tell how GDAL will handle its internal block buffers.
You can take a look at one of the drivers that I wrote as example:
http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/idrisi/IdrisiDataset.cpp#L500
http://trac.osgeo.org/gdal/browser/trunk/gdal/frmts/idrisi/IdrisiDataset.cpp#L1261
Regards,
Ivan
> -------Original Message-------
> From: Cherif Oueslati <oueslati.cherif at gmail.com>
> Subject: [gdal-dev] [GDAL dev][GDALRasterBand::IReadBlock] About how to read all the raster bands.
> Sent: Oct 10 '08 07:22
>
> Hello,
>
>
> I am implementing a format specific driver to add new format. So i have to
> read raster bands from a file in addition of the metadata given in the
> header.
>
> The gdalinfo.exe is working effeciently, by using an OGRSpatialReference
> object. However i found a problem with the gdal_translate.exe application.
>
>
> In fact, and when debugging, an error appears indicating that it's
> impossible to write in certain memory address, knowing that the input file
> to read contain 501 pixels (corresponding to nBlockXSize) and 501 lines
> (corresponding to nBlockYSize).
>
> To avoid this problem, i changed the number of iterations in the for loop,
> which is allowing reading all the raster bands and filling into the pImage,
> from (nBlockXSize*nBlockYSize) to (nBlockXSize*125).
>
> As a consequence i obtain an image that is a part of the whole image to
> read which is logic, since i'm not putting all the raster bands.
>
>
> So to summarise the problem: (nBlockXSize*125) is the maximum rows that i
> can put into the destination file image or i have to use all the
> (nBlockXSize*nBlockYSize) raster bands.
>
> I think that it's related to the default size of the destination file
> image.
>
> I used CPLMalloc, CPLRealloc, memset and memcpy functions but it was
> fruitless. Could you tell me how to modify this default size?
>
> Otherwise have you any other suggestions.
>
>
> With all my regards.
>
> Cherif OUESLATI
> --------------------
> _______________________________________________
> gdal-dev mailing list
> [LINK: compose.php?to=gdal-dev at lists.osgeo.org] gdal-dev at lists.osgeo.org
> [LINK: http://lists.osgeo.org/mailman/listinfo/gdal-dev]
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
More information about the gdal-dev
mailing list