[gdal-dev] regarding GDALDriver::Create
Srikanth
srikanth1947 at gmail.com
Fri Aug 14 02:59:07 EDT 2009
Dear All,
I am reading and writing raster images using GDAL. Below is the code which I
am using for writing a raster.
At times the code is working fine. But many a time , it is getting crashed
in the *GetRasterBand.* I have debugged the code several times and the
variables passed seems to be perfect. Any help in this is regard would be
appreciated.
bool GDALImageWriter::InitiliazeDataset(char* filename , int width , int
height , int numOfbands ,rasterDataType datatype){
this->imageWidth = width ;
this->imageHeight = height ;
this->numOfBands = numOfbands ;
this->datatpye = datatype ;
poBand = new GDALRasterBand*[numOfbands] ;
poDriver = GetGDALDriverManager()->GetDriverByName("GTiff");
//papszOptions = CSLSetNameValue( papszOptions, "TILED", "YES" );
//papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" );
poDataset=NULL;
*poDataset = poDriver->Create(filename , width , height , numOfbands
,(GDALDataType)datatype,NULL);*
for(int i=0 ; i < numOfbands ; i++)
{
poBand[i] = poDataset->GetRasterBand(i+1);
}
if(projectionStr != NULL)
poDataset->SetProjection(projectionStr);
if(adfGeoTransform != NULL)
poDataset->SetGeoTransform(adfGeoTransform);
if(poDataset == NULL)
return false ;
else
return true ;
}
bool GDALImageWriter::writeData(int x , int y , int blockWidth , int
blockHeight ,uchar* data){
for(int i=0 ; i < numOfBands ; i++){
poBand[i]->RasterIO(GF_Write, x, y, blockWidth, blockHeight,data,
blockWidth, blockHeight,(GDALDataType)this->datatpye, 0, 0);
}
}
bool GDALImageWriter::closeDataset(){
if(poDataset!=NULL)
GDALClose(poDataset);
}
--
Regards,
Srikanth K.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20090814/51130e3c/attachment-0001.html
More information about the gdal-dev
mailing list