本文整理汇总了C++中GDALRasterBand::SetColorInterpretation方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::SetColorInterpretation方法的具体用法?C++ GDALRasterBand::SetColorInterpretation怎么用?C++ GDALRasterBand::SetColorInterpretation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::SetColorInterpretation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
//.........这里部分代码省略.........
NULL, pProgressData ) )
{
VSIFCloseL( fp );
VSIFree( pfData );
CPLError( CE_Failure, CPLE_UserInterrupt, "User terminated" );
return NULL;
}
}
VSIFree( pfData );
/* write out the min and max values */
eErr = WriteHeader( fp, nXSize, nYSize,
dfMinX, dfMaxX, dfMinY, dfMaxY, dfMinZ, dfMaxZ );
if( eErr != CE_None )
{
VSIFCloseL( fp );
return NULL;
}
VSIFCloseL( fp );
GDALPamDataset *poDstDS = (GDALPamDataset *)GDALOpen( pszFilename,
GA_Update );
if( poDstDS == NULL )
{
VSIUnlink( pszFilename );
CPLError( CE_Failure, CPLE_FileIO,
"Unable to open copy of dataset.\n" );
return NULL;
}
else if( dynamic_cast<GSBGDataset *>(poDstDS) == NULL )
{
VSIUnlink( pszFilename );
delete poDstDS;
CPLError( CE_Failure, CPLE_FileIO,
"Copy dataset not opened as Golden Surfer Binary Grid!?\n" );
return NULL;
}
GDALRasterBand *poDstBand = poSrcDS->GetRasterBand(1);
if( poDstBand == NULL )
{
VSIUnlink( pszFilename );
delete poDstDS;
CPLError( CE_Failure, CPLE_FileIO,
"Unable to open copy of raster band?\n" );
return NULL;
}
/* -------------------------------------------------------------------- */
/* Attempt to copy metadata. */
/* -------------------------------------------------------------------- */
if( !bStrict )
CPLPushErrorHandler( CPLQuietErrorHandler );
/* non-zero transform 2 or 4 or negative 1 or 5 not supported natively */
/*if( adfGeoTransform[2] != 0.0 || adfGeoTransform[4] != 0.0
|| adfGeoTransform[1] < 0.0 || adfGeoTransform[5] < 0.0 )
poDstDS->GDALPamDataset::SetGeoTransform( adfGeoTransform );*/
const char *szProjectionRef = poSrcDS->GetProjectionRef();
if( *szProjectionRef != '\0' )
poDstDS->SetProjection( szProjectionRef );
char **pszMetadata = poSrcDS->GetMetadata();
if( pszMetadata != NULL )
poDstDS->SetMetadata( pszMetadata );
/* FIXME: Should the dataset description be copied as well, or is it
* always the file name? */
poDstBand->SetDescription( poSrcBand->GetDescription() );
int bSuccess;
double dfOffset = poSrcBand->GetOffset( &bSuccess );
if( bSuccess && dfOffset != 0.0 )
poDstBand->SetOffset( dfOffset );
double dfScale = poSrcBand->GetScale( &bSuccess );
if( bSuccess && dfScale != 1.0 )
poDstBand->SetScale( dfScale );
GDALColorInterp oColorInterp = poSrcBand->GetColorInterpretation();
if( oColorInterp != GCI_Undefined )
poDstBand->SetColorInterpretation( oColorInterp );
char **pszCatNames = poSrcBand->GetCategoryNames();
if( pszCatNames != NULL)
poDstBand->SetCategoryNames( pszCatNames );
GDALColorTable *poColorTable = poSrcBand->GetColorTable();
if( poColorTable != NULL )
poDstBand->SetColorTable( poColorTable );
if( !bStrict )
CPLPopErrorHandler();
return poDstDS;
}
示例2: Build
/* Builds a ECRGTOCSubDataset from the set of files of the toc entry */
GDALDataset* ECRGTOCSubDataset::Build( const char* pszProductTitle,
const char* pszDiscId,
int nScale,
int nCountSubDataset,
const char* pszTOCFilename,
const std::vector<FrameDesc>& aosFrameDesc,
double dfGlobalMinX,
double dfGlobalMinY,
double dfGlobalMaxX,
double dfGlobalMaxY,
double dfGlobalPixelXSize,
double dfGlobalPixelYSize)
{
int i, j;
GDALDriver *poDriver;
ECRGTOCSubDataset *poVirtualDS;
int nSizeX, nSizeY;
double adfGeoTransform[6];
poDriver = GetGDALDriverManager()->GetDriverByName("VRT");
if( poDriver == NULL )
return NULL;
nSizeX = (int)((dfGlobalMaxX - dfGlobalMinX) / dfGlobalPixelXSize + 0.5);
nSizeY = (int)((dfGlobalMaxY - dfGlobalMinY) / dfGlobalPixelYSize + 0.5);
/* ------------------------------------ */
/* Create the VRT with the overall size */
/* ------------------------------------ */
poVirtualDS = new ECRGTOCSubDataset( nSizeX, nSizeY );
poVirtualDS->SetProjection(SRS_WKT_WGS84);
adfGeoTransform[0] = dfGlobalMinX;
adfGeoTransform[1] = dfGlobalPixelXSize;
adfGeoTransform[2] = 0;
adfGeoTransform[3] = dfGlobalMaxY;
adfGeoTransform[4] = 0;
adfGeoTransform[5] = -dfGlobalPixelYSize;
poVirtualDS->SetGeoTransform(adfGeoTransform);
for (i=0;i<3;i++)
{
poVirtualDS->AddBand(GDT_Byte, NULL);
GDALRasterBand *poBand = poVirtualDS->GetRasterBand( i + 1 );
poBand->SetColorInterpretation((GDALColorInterp)(GCI_RedBand+i));
}
poVirtualDS->SetDescription(pszTOCFilename);
poVirtualDS->SetMetadataItem("PRODUCT_TITLE", pszProductTitle);
poVirtualDS->SetMetadataItem("DISC_ID", pszDiscId);
if (nScale != -1)
poVirtualDS->SetMetadataItem("SCALE", CPLString().Printf("%d", nScale));
/* -------------------------------------------------------------------- */
/* Check for overviews. */
/* -------------------------------------------------------------------- */
poVirtualDS->oOvManager.Initialize( poVirtualDS,
CPLString().Printf("%s.%d", pszTOCFilename, nCountSubDataset));
poVirtualDS->papszFileList = poVirtualDS->GDALDataset::GetFileList();
for(i=0;i<(int)aosFrameDesc.size(); i++)
{
const char* pszName = BuildFullName(pszTOCFilename,
aosFrameDesc[i].pszPath,
aosFrameDesc[i].pszName);
double dfMinX = 0, dfMaxX = 0, dfMinY = 0, dfMaxY = 0,
dfPixelXSize = 0, dfPixelYSize = 0;
GetExtent(aosFrameDesc[i].pszName,
aosFrameDesc[i].nScale, aosFrameDesc[i].nZone,
dfMinX, dfMaxX, dfMinY, dfMaxY, dfPixelXSize, dfPixelYSize);
int nFrameXSize = (int)((dfMaxX - dfMinX) / dfPixelXSize + 0.5);
int nFrameYSize = (int)((dfMaxY - dfMinY) / dfPixelYSize + 0.5);
poVirtualDS->papszFileList = CSLAddString(poVirtualDS->papszFileList, pszName);
/* We create proxy datasets and raster bands */
/* Using real datasets and raster bands is possible in theory */
/* However for large datasets, a TOC entry can include several hundreds of files */
/* and we finally reach the limit of maximum file descriptors open at the same time ! */
/* So the idea is to warp the datasets into a proxy and open the underlying dataset only when it is */
/* needed (IRasterIO operation). To improve a bit efficiency, we have a cache of opened */
/* underlying datasets */
ECRGTOCProxyRasterDataSet* poDS = new ECRGTOCProxyRasterDataSet(
(ECRGTOCSubDataset*)poVirtualDS, pszName, nFrameXSize, nFrameYSize,
dfMinX, dfMaxY, dfPixelXSize, dfPixelYSize);
for(j=0;j<3;j++)
{
VRTSourcedRasterBand *poBand = (VRTSourcedRasterBand*)
poVirtualDS->GetRasterBand( j + 1 );
/* Place the raster band at the right position in the VRT */
poBand->AddSimpleSource(poDS->GetRasterBand(j + 1),
0, 0, nFrameXSize, nFrameYSize,
//.........这里部分代码省略.........
示例3: generateRaster
//.........这里部分代码省略.........
double scale = pc->getGlobalScale();
assert(scale != 0);
stepX /= scale;
stepY /= scale;
}
double adfGeoTransform[6] = { shiftX, //top left x
stepX, //w-e pixel resolution (can be negative)
0, //0
shiftY, //top left y
0, //0
stepY //n-s pixel resolution (can be negative)
};
poDstDS->SetGeoTransform( adfGeoTransform );
//OGRSpatialReference oSRS;
//oSRS.SetUTM( 11, TRUE );
//oSRS.SetWellKnownGeogCS( "NAD27" );
//char *pszSRS_WKT = NULL;
//oSRS.exportToWkt( &pszSRS_WKT );
//poDstDS->SetProjection( pszSRS_WKT );
//CPLFree( pszSRS_WKT );
double* scanline = (double*) CPLMalloc(sizeof(double)*m_grid.width);
int currentBand = 0;
//exort height band?
if (heightBand)
{
GDALRasterBand* poBand = poDstDS->GetRasterBand(++currentBand);
assert(poBand);
poBand->SetColorInterpretation(GCI_Undefined);
EmptyCellFillOption fillEmptyCellsStrategy = getFillEmptyCellsStrategy(fillEmptyCellsComboBox);
double emptyCellHeight = 0;
switch (fillEmptyCellsStrategy)
{
case LEAVE_EMPTY:
emptyCellHeight = m_grid.minHeight-1.0;
poBand->SetNoDataValue(emptyCellHeight); //should be transparent!
break;
case FILL_MINIMUM_HEIGHT:
emptyCellHeight = m_grid.minHeight;
break;
case FILL_MAXIMUM_HEIGHT:
emptyCellHeight = m_grid.maxHeight;
break;
case FILL_CUSTOM_HEIGHT:
emptyCellHeight = getCustomHeightForEmptyCells();
break;
case FILL_AVERAGE_HEIGHT:
emptyCellHeight = m_grid.meanHeight;
break;
default:
assert(false);
}
for (unsigned j=0; j<m_grid.height; ++j)
{
const RasterCell* aCell = m_grid.data[j];
for (unsigned i=0; i<m_grid.width; ++i,++aCell)
{
scanline[i] = aCell->h == aCell->h ? aCell->h : emptyCellHeight;