本文整理汇总了C++中GDALRasterBand::GetBlockSize方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::GetBlockSize方法的具体用法?C++ GDALRasterBand::GetBlockSize怎么用?C++ GDALRasterBand::GetBlockSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::GetBlockSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: import_raster
Raster* import_raster(string raster_filename, int band_number) {
GDALAllRegister();
GDALDataset* poDataset = (GDALDataset *) GDALOpen( raster_filename.c_str(), GA_ReadOnly );
if( poDataset == NULL ) {
cerr << "Error: Could not open raster data file" << endl;
exit(1);
}
fprintf(stderr, "Driver: %s/%s\n", poDataset->GetDriver()->GetDescription(), poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );
fprintf(stderr, "Size is %dx%dx%d\n", poDataset->GetRasterXSize(), poDataset->GetRasterYSize(), poDataset->GetRasterCount() );
if( poDataset->GetProjectionRef() != NULL ) cerr << "Projection is `" << poDataset->GetProjectionRef() << "'" << endl;;
GDALRasterBand* poBand = poDataset->GetRasterBand( band_number );
int nBlockXSize, nBlockYSize;
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
fprintf(stderr, "Block=%dx%d Type=%s, ColorInterp=%s\n",
nBlockXSize, nBlockYSize,
GDALGetDataTypeName(poBand->GetRasterDataType()),
GDALGetColorInterpretationName( poBand->GetColorInterpretation()) );
Raster* raster = extract_raster_attributes( poDataset );
raster->band = poBand;
return raster;
}
示例2: MetaDataInfo
void DemReader::MetaDataInfo(GDALDataset* gdalDataset, MapControllerPtr mapController)
{
FileMetaData* header = mapController->GetMapModel()->GetMetaData();
header->driverDesc = gdalDataset->GetDriver()->GetDescription();
header->driverMetaData = gdalDataset->GetDriver()->GetMetadataItem(GDAL_DMD_LONGNAME);
Log::Inst().Write("Driver: " + header->driverDesc + " \\ " + header->driverMetaData);
header->xSize = gdalDataset->GetRasterXSize();
header->ySize = gdalDataset->GetRasterYSize();
header->bands = gdalDataset->GetRasterCount();
Log::Inst().Write("Size (x,y): " +
StringTools::ToString(header->xSize) + ", " +
StringTools::ToString(header->ySize));
Log::Inst().Write("Bands: " + StringTools::ToString(header->bands));
header->projection = std::string(gdalDataset->GetProjectionRef());
Log::Inst().Write("Projection: " + header->projection);
double adfGeoTransform[6];
gdalDataset->GetGeoTransform( adfGeoTransform );
header->originX = adfGeoTransform[0];
header->originY = adfGeoTransform[3];
Log::Inst().Write("Origin: " +
StringTools::ToString(adfGeoTransform[0]) + ", " +
StringTools::ToString(adfGeoTransform[3]));
header->pixelSizeX = adfGeoTransform[1];
header->pixelSizeY = adfGeoTransform[5];
Log::Inst().Write("Pixel Size: " +
StringTools::ToString(adfGeoTransform[1]) + ", " +
StringTools::ToString(adfGeoTransform[5]));
GDALRasterBand* gdalBand = gdalDataset->GetRasterBand(1);
int nBlockXSize, nBlockYSize;
gdalBand->GetBlockSize(&nBlockXSize, &nBlockYSize);
header->dataType = std::string(GDALGetDataTypeName(gdalBand->GetRasterDataType()));
Log::Inst().Write("Block, Type: " + StringTools::ToString(nBlockXSize) + ", " +
StringTools::ToString(nBlockYSize) + ", " +
std::string(header->dataType));
header->colourInterpretation = std::string(GDALGetColorInterpretationName(gdalBand->GetColorInterpretation()));
Log::Inst().Write("Color Interpretation: " + header->colourInterpretation);
header->extents.x = adfGeoTransform[0];
header->extents.y = adfGeoTransform[3] + gdalBand->GetYSize()*adfGeoTransform[5];
Log::Inst().Write("Lower, Left (x,y): " +
StringTools::ToString(header->extents.x) + ", " +
StringTools::ToString(header->extents.y));
header->extents.dx = adfGeoTransform[0]+gdalBand->GetXSize()*adfGeoTransform[1];
header->extents.dy = adfGeoTransform[3];
Log::Inst().Write("Upper, Right (x,y): " +
StringTools::ToString(header->extents.dx) + ", " +
StringTools::ToString(header->extents.dy));
Log::Inst().Write("");
}
示例3: SetMetadataItem
TSXRasterBand::TSXRasterBand( TSXDataset *poDS, GDALDataType eDataType,
ePolarization ePol, GDALDataset *poBand )
{
this->poDS = poDS;
this->eDataType = eDataType;
this->ePol = ePol;
switch (ePol) {
case HH:
SetMetadataItem( "POLARIMETRIC_INTERP", "HH" );
break;
case HV:
SetMetadataItem( "POLARIMETRIC_INTERP", "HV" );
break;
case VH:
SetMetadataItem( "POLARIMETRIC_INTERP", "VH" );
break;
case VV:
SetMetadataItem( "POLARIMETRIC_INTERP", "VV" );
break;
}
/* now setup the actual raster reader */
this->poBand = poBand;
GDALRasterBand *poSrcBand = poBand->GetRasterBand( 1 );
poSrcBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
}
示例4: poBand
TSXRasterBand::TSXRasterBand( TSXDataset *poDSIn, GDALDataType eDataTypeIn,
ePolarization ePolIn, GDALDataset *poBandIn ) :
poBand(poBandIn),
ePol(ePolIn)
{
poDS = poDSIn;
eDataType = eDataTypeIn;
switch (ePol) {
case HH:
SetMetadataItem( "POLARIMETRIC_INTERP", "HH" );
break;
case HV:
SetMetadataItem( "POLARIMETRIC_INTERP", "HV" );
break;
case VH:
SetMetadataItem( "POLARIMETRIC_INTERP", "VH" );
break;
case VV:
SetMetadataItem( "POLARIMETRIC_INTERP", "VV" );
break;
}
/* now setup the actual raster reader */
GDALRasterBand *poSrcBand = poBandIn->GetRasterBand( 1 );
poSrcBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
}
示例5: CALSRasterBand
CALSRasterBand( CALSDataset* poDSIn )
{
poDS = poDSIn;
poUnderlyingBand = poDSIn->poUnderlyingDS->GetRasterBand(1);
poUnderlyingBand->GetBlockSize(&nBlockXSize, &nBlockYSize);
nBand = 1;
eDataType = GDT_Byte;
}
示例6: getRawValuesFromFile
bool getRawValuesFromFile(string fname,vector<vector<float>>& vecs)
{
//vector<float> temp = vector<float>()
GDALDataset *poDataset;
GDALAllRegister();
poDataset= (GDALDataset*) GDALOpen(fname.c_str(),GA_ReadOnly);
if(poDataset == NULL)
{
cout << "OUCH!" << endl;
return false;
}
cout << "Data size: " << GDALGetRasterXSize(poDataset) << " " << GDALGetRasterYSize(poDataset) << endl;
GDALRasterBand *poBand;
int nBlockXSize, nBlockYSize;
int bGotMin, bGotMax;
double adfMinMax[2];
poBand = poDataset->GetRasterBand( 1 );
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
printf( "Block=%dx%d Type=%s, ColorInterp=%s\n",
nBlockXSize, nBlockYSize,
GDALGetDataTypeName(poBand->GetRasterDataType()),
GDALGetColorInterpretationName(
poBand->GetColorInterpretation()) );
adfMinMax[0] = poBand->GetMinimum( &bGotMin );
adfMinMax[1] = poBand->GetMaximum( &bGotMax );
if( ! (bGotMin && bGotMax) )
GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax);
int width = poBand->GetXSize();
int height = poBand->GetYSize();
int bands = poDataset->GetRasterCount();
float *pafScanline;
std::cout << "Before allocation" << adfMinMax[0] << " " << adfMinMax[1] << endl;
int dsize = 256;
pafScanline = (float *) CPLMalloc(sizeof(float)*width*height);
vector<vector<float>> out = vector<vector<float>>(height,vector<float> (width,0));
poBand->RasterIO(GF_Read,0,0,width,height,pafScanline,width,height,GDT_Float32,0,0);
cout << "After allocation" << endl;
for(int i = 0; i < height; i++)
{
for(int j = 0; j < width; j++)
{
//cout << i << j << endl << pafS;
out[i][j] = pafScanline[i*width+j];
}
}
CPLFree(pafScanline);
//for(auto i : out)
//for(auto j : i)
// cout << j << endl;
cout << "After allocation" << endl;
vecs = out;
return true;
}
示例7: main
int main()
{
GDALDataset *poDataset;
GDALAllRegister();
poDataset = (GDALDataset *) GDALOpen( "GE01.tif", GA_ReadOnly );
printf("Working! \n");
if( poDataset != NULL ){
//Get Dataset Information
double adfGeoTransform[6];
printf( "Driver: %s/%s\n", poDataset->GetDriver()->GetDescription(), poDataset->GetDriver()->GetMetadataItem( GDAL_DMD_LONGNAME ) );
printf( "Size is %dx%dx%d\n", poDataset->GetRasterXSize(), poDataset->GetRasterYSize(), poDataset->GetRasterCount() );
if( poDataset->GetProjectionRef() != NULL )
printf( "Projection is `%s'\n", poDataset->GetProjectionRef() );
if( poDataset->GetGeoTransform( adfGeoTransform ) == CE_None ){
printf( "Origin = (%.6f,%.6f)\n",
adfGeoTransform[0], adfGeoTransform[3] );
printf( "Pixel Size = (%.6f,%.6f)\n",
adfGeoTransform[1], adfGeoTransform[5] );
}
//Fetch Raster Band
GDALRasterBand *poBand;
int nBlockXSize, nBlockYSize;
int bGotMin, bGotMax;
double adfMinMax[2];
poBand = poDataset->GetRasterBand( 1 );
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
printf( "Block=%dx%d Type=%s, ColorInterp=%s\n",
nBlockXSize, nBlockYSize,
GDALGetDataTypeName(poBand->GetRasterDataType()),
GDALGetColorInterpretationName(
poBand->GetColorInterpretation()) );
adfMinMax[0] = poBand->GetMinimum( &bGotMin );
adfMinMax[1] = poBand->GetMaximum( &bGotMax );
if( ! (bGotMin && bGotMax) )
GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax);
printf( "Min=%.3fd, Max=%.3f\n", adfMinMax[0], adfMinMax[1] );
if( poBand->GetOverviewCount() > 0 )
printf( "Band has %d overviews.\n", poBand->GetOverviewCount() );
if( poBand->GetColorTable() != NULL )
printf( "Band has a color table with %d entries.\n",
poBand->GetColorTable()->GetColorEntryCount() );
//Close Dataset
GDALClose(poDataset);
//Exit
return 0;
}
}
示例8: ReadBlock
int GDAL_EDBFile::ReadBlock( int channel,
int block_index, void *buffer,
int win_xoff, int win_yoff,
int win_xsize, int win_ysize )
{
GDALRasterBand *poBand = poDS->GetRasterBand(channel);
int nBlockXSize, nBlockYSize;
int nBlockX, nBlockY;
int nWidthInBlocks;
int nPixelOffset;
int nLineOffset;
if( GetType(channel) == CHN_UNKNOWN )
{
ThrowPCIDSKException("%s channel type not supported for PCIDSK access.",
GDALGetDataTypeName(poBand->GetRasterDataType()) );
}
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
nWidthInBlocks = (poBand->GetXSize() + nBlockXSize - 1) / nBlockXSize;
nBlockX = block_index % nWidthInBlocks;
nBlockY = block_index / nWidthInBlocks;
nPixelOffset = GDALGetDataTypeSize(poBand->GetRasterDataType()) / 8;
nLineOffset = win_xsize * nPixelOffset;
/* -------------------------------------------------------------------- */
/* Are we reading a partial block at the edge of the database? */
/* If so, ensure we don't read off the database. */
/* -------------------------------------------------------------------- */
if( nBlockX * nBlockXSize + win_xoff + win_xsize > poBand->GetXSize() )
win_xsize = poBand->GetXSize() - nBlockX * nBlockXSize - win_xoff;
if( nBlockY * nBlockYSize + win_yoff + win_ysize > poBand->GetYSize() )
win_ysize = poBand->GetYSize() - nBlockY * nBlockYSize - win_yoff;
CPLErr eErr = poBand->RasterIO( GF_Read,
nBlockX * nBlockXSize + win_xoff,
nBlockY * nBlockYSize + win_yoff,
win_xsize, win_ysize,
buffer, win_xsize, win_ysize,
poBand->GetRasterDataType(),
nPixelOffset, nLineOffset, NULL );
if( eErr != CE_None )
{
ThrowPCIDSKException( "%s", CPLGetLastErrorMsg() );
}
return 1;
}
示例9: getGDALRasterPtr
SEXP
RGDAL_GetRasterBlockSize(SEXP rasterObj) {
GDALRasterBand *raster = getGDALRasterPtr(rasterObj);
SEXP blockSize = allocVector(INTSXP, 2);
raster->GetBlockSize(INTEGER(blockSize) + 1, INTEGER(blockSize));
return(blockSize);
}
示例10: WriteBlock
int GDAL_EDBFile::WriteBlock( int channel, int block_index, void *buffer)
{
GDALRasterBand *poBand = poDS->GetRasterBand(channel);
int nBlockXSize, nBlockYSize;
int nBlockX, nBlockY;
int nWinXSize, nWinYSize;
int nWidthInBlocks;
if( GetType(channel) == CHN_UNKNOWN )
{
ThrowPCIDSKException("%s channel type not supported for PCIDSK access.",
GDALGetDataTypeName(poBand->GetRasterDataType()) );
}
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
nWidthInBlocks = (poBand->GetXSize() + nBlockXSize - 1) / nBlockXSize;
nBlockX = block_index % nWidthInBlocks;
nBlockY = block_index / nWidthInBlocks;
/* -------------------------------------------------------------------- */
/* Are we reading a partial block at the edge of the database? */
/* If so, ensure we don't read off the database. */
/* -------------------------------------------------------------------- */
if( nBlockX * nBlockXSize + nBlockXSize > poBand->GetXSize() )
nWinXSize = poBand->GetXSize() - nBlockX * nBlockXSize;
else
nWinXSize = nBlockXSize;
if( nBlockY * nBlockYSize + nBlockYSize > poBand->GetYSize() )
nWinYSize = poBand->GetYSize() - nBlockY * nBlockYSize;
else
nWinYSize = nBlockYSize;
CPLErr eErr = poBand->RasterIO( GF_Write,
nBlockX * nBlockXSize,
nBlockY * nBlockYSize,
nWinXSize, nWinYSize,
buffer, nWinXSize, nWinYSize,
poBand->GetRasterDataType(), 0, 0, NULL );
if( eErr != CE_None )
{
ThrowPCIDSKException( "%s", CPLGetLastErrorMsg() );
}
return 1;
}
示例11: poBandFile
SAFERasterBand::SAFERasterBand( SAFEDataset *poDSIn,
GDALDataType eDataTypeIn,
const char *pszSwath,
const char *pszPolarisation,
GDALDataset *poBandFileIn ) :
poBandFile(poBandFileIn)
{
poDS = poDSIn;
GDALRasterBand *poSrcBand = poBandFile->GetRasterBand( 1 );
poSrcBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
eDataType = eDataTypeIn;
if( *pszSwath != '\0' ) {
SetMetadataItem( "SWATH", pszSwath );
}
if( *pszPolarisation != '\0' ) {
SetMetadataItem( "POLARISATION", pszPolarisation );
}
}
示例12: ProxyMain
//.........这里部分代码省略.........
nRasterCount, GDT_Byte, papszCreateOptions);
printf("created\n");
if( hOutDS != NULL )
{
hDataset->GetGeoTransform( adfGeoTransform);
hOutDS->SetGeoTransform( adfGeoTransform );
hOutDS->SetProjection( hDataset->GetProjectionRef() );
/* ==================================================================== */
/* Process all bands. */
/* ==================================================================== */
// if (0)
for( i = 1; i < nRasterCount+1; i++ )
{
inBand = hDataset->GetRasterBand( i );
// hOutDS->AddBand(GDT_Byte);
outBand = hOutDS->GetRasterBand( i );
CopyBandInfo( inBand, outBand, 0, 1, 1 );
nRasterXSize = inBand->GetXSize( );
nRasterYSize = inBand->GetYSize( );
GByte old_value, new_value;
// char tmp_value[255];
// const char *tmp_value2;
std::map<GByte,GByte>::iterator it;
//tmp
int nXBlocks, nYBlocks, nXBlockSize, nYBlockSize;
int iXBlock, iYBlock;
inBand->GetBlockSize( &nXBlockSize, &nYBlockSize );
// nXBlockSize = nXBlockSize / 4;
// nYBlockSize = nYBlockSize / 4;
nXBlocks = (inBand->GetXSize() + nXBlockSize - 1) / nXBlockSize;
nYBlocks = (inBand->GetYSize() + nYBlockSize - 1) / nYBlockSize;
printf("blocks: %d %d %d %d\n",nXBlockSize,nYBlockSize,nXBlocks,nYBlocks);
printf("TMP ET creating raster %d x %d\n",nRasterXSize, nRasterYSize);
// srcBuffer = new GByte[nRasterXSize * nRasterYSize];
// printf("reading\n");
// inBand->RasterIO( GF_Read, 0, 0, nRasterXSize, nRasterYSize,
// srcBuffer, nRasterXSize, nRasterYSize, GDT_Byte,
// 0, 0 );
// srcBuffer = (GByte *) CPLMalloc(sizeof(GByte)*nRasterXSize * nRasterYSize);
srcBuffer = (GByte *) CPLMalloc(nXBlockSize * nYBlockSize);
for( iYBlock = 0; iYBlock < nYBlocks; iYBlock++ )
{
// if(iYBlock%1000 == 0)
// printf("iXBlock: %d iYBlock: %d\n",iXBlock,iYBlock);
if(iYBlock%1000 == 0)
printf("iYBlock: %d / %d\n",iYBlock,nYBlocks);
for( iXBlock = 0; iXBlock < nXBlocks; iXBlock++ )
{
int nXValid, nYValid;
// inBand->ReadBlock( iXBlock, iYBlock, srcBuffer );
inBand->RasterIO( GF_Read, iXBlock, iYBlock, nXBlockSize, nYBlockSize,
srcBuffer, nXBlockSize, nYBlockSize, GDT_Byte,
0, 0 );
示例13: GISToFloatArray
T* GISToFloatArray(char* fname, int interpWidth, int interpHeight)
{
// Important note ------ Gdal considers images to be north up
// the origin of datasets takes place in the upper-left or North-West corner.
// Now to create a GDAL dataset
// auto ds = ((GDALDataset*) GDALOpen(fname,GA_ReadOnly));
GDALDataset* ds = ((GDALDataset*) GDALOpen(fname,GA_ReadOnly));
if(ds == NULL)
{
return NULL;
}
// Creating a Raster band variable
// A band represents one whole dataset within a dataset
// in your case your files have one band.
GDALRasterBand *poBand;
int nBlockXSize, nBlockYSize;
int bGotMin, bGotMax;
double adfMinMax[2];
// Assign the band
poBand = ds->GetRasterBand( 1 );
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
// find the min and max
adfMinMax[0] = poBand->GetMinimum( &bGotMin );
adfMinMax[1] = poBand->GetMaximum( &bGotMax );
if( ! (bGotMin && bGotMax) )
GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax);
int min = adfMinMax[0];
int max = adfMinMax[1];
// get the width and height of the band or dataset
int width = poBand->GetXSize();
int height = poBand->GetYSize();
// GDAL can handle files that have multiple datasets jammed witin it
int bands = ds->GetRasterCount();
// the float variable to hold the DEM!
T *pafScanline;
// std::cout << "Min: " << adfMinMax[0] << " Max: " << adfMinMax[1] << endl;
int dsize = 256;
// pafScanline = (T *) CPLMalloc(sizeof(T)*width*height);
pafScanline = (T *) CPLMalloc(sizeof(T)*interpWidth*interpHeight);
// Lets acquire the data. ..... this funciton will interpolate for you
// poBand->RasterIO(GF_Read,0,0,width,height,pafScanline,width,height,GDT_Float32,0,0);
poBand->RasterIO(GF_Read,0,0,width,height,pafScanline,interpWidth,interpHeight,GDT_Float32,0,0);
// chage these two to interpolate automatically ^ ^
// The Geotransform gives information on where a dataset is located in the world
// and the resolution.
// for more information look at http://www.gdal.org/gdal_datamodel.html
double geot[6];
ds->GetGeoTransform(geot);
// Get the x resolution per pixel(south and west) and y resolution per pixel (north and south)
// float xres = geot[1];
// float yres = geot[5];
// string proj;
// proj = string(ds->GetProjectionRef());
// You can get the projection string
// The projection gives information about the coordinate system a dataset is in
// This is important to allow other GIS softwares to place datasets into the same
// coordinate space
// char* test = &proj[0];
// The origin of the dataset
// float startx = geot[0]; // east - west coord.
// float starty = geot[3]; // north - south coord.
// here is some code that I used to push that 1D array into a 2D array
// I believe this puts everything in the correct order....
/*for(int i = 0; i < hsize; i++)
{
for(int j = 0; j < wsize; j++)
{
//cout << i << j << endl << pafS;
vecs[i][j] = pafScanline[((int)i)*(int)wsize+((int)j)];
if(vecs[i][j]>0 && vecs[i][j] > max)
{
max = vecs[i][j];
}
if(vecs[i][j]>0 && vecs[i][j] < min)
{
min = vecs[i][j];
}
}
}*/
//CPLFree(pafScanline);
return pafScanline;
}
示例14: loadFile
//.........这里部分代码省略.........
double y = adfGeoTransform[3] + static_cast<double>(j) * adfGeoTransform[5] + Pshift.y;
CCVector3 P( 0,
static_cast<PointCoordinateType>(y),
static_cast<PointCoordinateType>(z));
for (int i=0; i<rasterX; ++i)
{
double x = adfGeoTransform[0] + static_cast<double>(i) * adfGeoTransform[1] + Pshift.x;
P.x = static_cast<PointCoordinateType>(x);
pc->addPoint(P);
}
}
QVariant xVar = QVariant::fromValue<int>(rasterX);
QVariant yVar = QVariant::fromValue<int>(rasterY);
pc->setMetaData("raster_width",xVar);
pc->setMetaData("raster_height",yVar);
}
//fetch raster bands
bool zRasterProcessed = false;
unsigned zInvalid = 0;
double zMinMax[2] = {0, 0};
for (int i=1; i<=rasterCount; ++i)
{
ccLog::Print( "Reading band #%i", i);
GDALRasterBand* poBand = poDataset->GetRasterBand(i);
GDALColorInterp colorInterp = poBand->GetColorInterpretation();
GDALDataType bandType = poBand->GetRasterDataType();
int nBlockXSize, nBlockYSize;
poBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
ccLog::Print( "Block=%dx%d Type=%s, ColorInterp=%s", nBlockXSize, nBlockYSize, GDALGetDataTypeName(poBand->GetRasterDataType()), GDALGetColorInterpretationName(colorInterp) );
//fetching raster scan-line
int nXSize = poBand->GetXSize();
int nYSize = poBand->GetYSize();
assert(nXSize == rasterX);
assert(nYSize == rasterY);
int bGotMin, bGotMax;
double adfMinMax[2] = {0, 0};
adfMinMax[0] = poBand->GetMinimum( &bGotMin );
adfMinMax[1] = poBand->GetMaximum( &bGotMax );
if (!bGotMin || !bGotMax )
//DGM FIXME: if the file is corrupted (e.g. ASCII ArcGrid with missing rows) this method will enter in a infinite loop!
GDALComputeRasterMinMax((GDALRasterBandH)poBand, TRUE, adfMinMax);
ccLog::Print( "Min=%.3fd, Max=%.3f", adfMinMax[0], adfMinMax[1] );
GDALColorTable* colTable = poBand->GetColorTable();
if( colTable != NULL )
printf( "Band has a color table with %d entries", colTable->GetColorEntryCount() );
if( poBand->GetOverviewCount() > 0 )
printf( "Band has %d overviews", poBand->GetOverviewCount() );
if (colorInterp == GCI_Undefined && !zRasterProcessed/*&& !colTable*/) //probably heights?
{
zRasterProcessed = true;
zMinMax[0] = adfMinMax[0];
zMinMax[1] = adfMinMax[1];
double* scanline = (double*) CPLMalloc(sizeof(double)*nXSize);
//double* scanline = new double[nXSize];
示例15: CPLError
//.........这里部分代码省略.........
delete poDstDS->GetRasterBand(i);
}
poDstDS->nBands = 0;
if( poDstDS->hHeaderOne.DataTypeCode == Uncompressed24bit )
{
poDstDS->SetBand( 1, new IntergraphRGBBand( poDstDS, 1, 0, 3 ) );
poDstDS->SetBand( 2, new IntergraphRGBBand( poDstDS, 2, 0, 2 ) );
poDstDS->SetBand( 3, new IntergraphRGBBand( poDstDS, 3, 0, 1 ) );
poDstDS->nBands = 3;
}
else
{
for( int i = 1; i <= poSrcDS->GetRasterCount(); i++ )
{
poSrcBand = poSrcDS->GetRasterBand(i);
eType = poSrcDS->GetRasterBand(i)->GetRasterDataType();
poDstBand = new IntergraphRasterBand( poDstDS, i, 0, eType );
poDstDS->SetBand( i, poDstBand );
poDstBand->SetCategoryNames( poSrcBand->GetCategoryNames() );
poDstBand->SetColorTable( poSrcBand->GetColorTable() );
poSrcBand->GetStatistics( false, true, &dfMin, &dfMax, &dfMean, &dfStdDev );
poDstBand->SetStatistics( dfMin, dfMax, dfMean, dfStdDev );
}
}
// --------------------------------------------------------------------
// Copy image data
// --------------------------------------------------------------------
int nXSize = poDstDS->GetRasterXSize();
int nYSize = poDstDS->GetRasterYSize();
int nBlockXSize;
int nBlockYSize;
CPLErr eErr = CE_None;
for( int iBand = 1; iBand <= poSrcDS->GetRasterCount(); iBand++ )
{
GDALRasterBand *poDstBand = poDstDS->GetRasterBand( iBand );
GDALRasterBand *poSrcBand = poSrcDS->GetRasterBand( iBand );
// ------------------------------------------------------------
// Copy Untiled / Uncompressed
// ------------------------------------------------------------
int iYOffset, iXOffset;
void *pData;
poSrcBand->GetBlockSize( &nBlockXSize, &nBlockYSize );
nBlockXSize = nXSize;
nBlockYSize = 1;
pData = CPLMalloc( nBlockXSize * nBlockYSize * GDALGetDataTypeSize( eType ) / 8 );
for( iYOffset = 0; iYOffset < nYSize; iYOffset += nBlockYSize )
{
for( iXOffset = 0; iXOffset < nXSize; iXOffset += nBlockXSize )
{
eErr = poSrcBand->RasterIO( GF_Read,
iXOffset, iYOffset,
nBlockXSize, nBlockYSize,
pData, nBlockXSize, nBlockYSize,
eType, 0, 0, NULL );
if( eErr != CE_None )
{
return NULL;
}
eErr = poDstBand->RasterIO( GF_Write,
iXOffset, iYOffset,
nBlockXSize, nBlockYSize,
pData, nBlockXSize, nBlockYSize,
eType, 0, 0, NULL );
if( eErr != CE_None )
{
return NULL;
}
}
if( ( eErr == CE_None ) && ( ! pfnProgress(
( iYOffset + 1 ) / ( double ) nYSize, NULL, pProgressData ) ) )
{
eErr = CE_Failure;
CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated CreateCopy()" );
}
}
CPLFree( pData );
}
// --------------------------------------------------------------------
// Finalize
// --------------------------------------------------------------------
poDstDS->FlushCache();
return poDstDS;
}