本文整理汇总了C++中GDALRasterBand::GetScale方法的典型用法代码示例。如果您正苦于以下问题:C++ GDALRasterBand::GetScale方法的具体用法?C++ GDALRasterBand::GetScale怎么用?C++ GDALRasterBand::GetScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GDALRasterBand
的用法示例。
在下文中一共展示了GDALRasterBand::GetScale方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getGDALRasterPtr
SEXP
RGDAL_GetScale(SEXP sxpRasterBand) {
GDALRasterBand *pRasterBand = getGDALRasterPtr(sxpRasterBand);
return(ScalarReal(pRasterBand->GetScale()));
}
示例2: FlushCache
void ROIPACDataset::FlushCache( void )
{
RawDataset::FlushCache();
GDALRasterBand *band = (GetRasterCount() > 0) ? GetRasterBand(1) : NULL;
if ( eAccess == GA_ReadOnly || band == NULL )
return;
// If opening an existing file in Update mode (i.e. "r+") we need to make
// sure any existing content is cleared, otherwise the file may contain
// trailing content from the previous write.
CPL_IGNORE_RET_VAL(VSIFTruncateL( fpRsc, 0 ));
CPL_IGNORE_RET_VAL(VSIFSeekL( fpRsc, 0, SEEK_SET ));
/* -------------------------------------------------------------------- */
/* Rewrite out the header. */
/* -------------------------------------------------------------------- */
/* -------------------------------------------------------------------- */
/* Raster dimensions. */
/* -------------------------------------------------------------------- */
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %d\n", "WIDTH", nRasterXSize ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %d\n", "FILE_LENGTH", nRasterYSize ));
/* -------------------------------------------------------------------- */
/* Georeferencing. */
/* -------------------------------------------------------------------- */
if ( pszProjection != NULL )
{
char *pszProjectionTmp = pszProjection;
OGRSpatialReference oSRS;
if( oSRS.importFromWkt( &pszProjectionTmp ) == OGRERR_NONE )
{
int bNorth;
int iUTMZone = oSRS.GetUTMZone( &bNorth );
if ( iUTMZone != 0 )
{
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %s%d\n", "PROJECTION", "UTM", iUTMZone ));
}
else if ( oSRS.IsGeographic() )
{
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %s\n", "PROJECTION", "LL" ));
}
else
{
CPLError( CE_Warning, CPLE_AppDefined,
"ROI_PAC format only support Latitude/Longitude and "
"UTM projections, discarding projection.");
}
if ( oSRS.GetAttrValue( "DATUM" ) != NULL )
{
if ( strcmp( oSRS.GetAttrValue( "DATUM" ), "WGS_1984" ) == 0 )
{
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %s\n", "DATUM", "WGS84" ));
}
else
{
CPLError( CE_Warning, CPLE_AppDefined,
"Datum \"%s\" probably not supported in the "
"ROI_PAC format, saving it anyway",
oSRS.GetAttrValue( "DATUM" ) );
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %s\n", "DATUM", oSRS.GetAttrValue( "DATUM" ) ));
}
}
if ( oSRS.GetAttrValue( "UNIT" ) != NULL )
{
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %s\n", "X_UNIT", oSRS.GetAttrValue( "UNIT" ) ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %s\n", "Y_UNIT", oSRS.GetAttrValue( "UNIT" ) ));
}
}
}
if( bValidGeoTransform )
{
if ( adfGeoTransform[2] != 0 || adfGeoTransform[4] != 0 )
{
CPLError( CE_Warning, CPLE_AppDefined,
"ROI_PAC format do not support geotransform with "
"rotation, discarding info.");
}
else
{
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %.16g\n", "X_FIRST", adfGeoTransform[0] ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %.16g\n", "X_STEP", adfGeoTransform[1] ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %.16g\n", "Y_FIRST", adfGeoTransform[3] ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %.16g\n", "Y_STEP", adfGeoTransform[5] ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %.16g\n", "Z_OFFSET", band->GetOffset(NULL) ));
CPL_IGNORE_RET_VAL(VSIFPrintfL( fpRsc, "%-40s %.16g\n", "Z_SCALE", band->GetScale(NULL) ));
}
}
/* -------------------------------------------------------------------- */
/* Metadata stored in the ROI_PAC domain. */
/* -------------------------------------------------------------------- */
char** papszROIPACMetadata = GetMetadata( "ROI_PAC" );
for (int i = 0; i < CSLCount( papszROIPACMetadata ); i++)
{
/* Get the tokens from the metadata item */
char **papszTokens = CSLTokenizeString2( papszROIPACMetadata[i],
"=",
//.........这里部分代码省略.........
示例3: 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;
}
示例4: ProxyMain
//.........这里部分代码省略.........
{
poVRTBand->AddMaskBandSource(poSrcBand);
continue;
}
/* -------------------------------------------------------------------- */
/* Do we need to collect scaling information? */
/* -------------------------------------------------------------------- */
double dfScale = 1.0, dfOffset = 0.0;
if (bScale && !bHaveScaleSrc)
{
double adfCMinMax[2];
GDALComputeRasterMinMax(poSrcBand, TRUE, adfCMinMax);
dfScaleSrcMin = adfCMinMax[0];
dfScaleSrcMax = adfCMinMax[1];
}
if (bScale)
{
if (dfScaleSrcMax == dfScaleSrcMin)
dfScaleSrcMax += 0.1;
if (dfScaleDstMax == dfScaleDstMin)
dfScaleDstMax += 0.1;
dfScale = (dfScaleDstMax - dfScaleDstMin)
/ (dfScaleSrcMax - dfScaleSrcMin);
dfOffset = -1 * dfScaleSrcMin * dfScale + dfScaleDstMin;
}
if (bUnscale)
{
dfScale = poSrcBand->GetScale();
dfOffset = poSrcBand->GetOffset();
}
/* -------------------------------------------------------------------- */
/* Create a simple or complex data source depending on the */
/* translation type required. */
/* -------------------------------------------------------------------- */
if (bUnscale || bScale || (nRGBExpand != 0 && i < nRGBExpand))
{
poVRTBand->AddComplexSource(poSrcBand,
anSrcWin[0], anSrcWin[1],
anSrcWin[2], anSrcWin[3],
0, 0, nOXSize, nOYSize,
dfOffset, dfScale,
VRT_NODATA_UNSET,
nComponent);
}
else
poVRTBand->AddSimpleSource(poSrcBand,
anSrcWin[0], anSrcWin[1],
anSrcWin[2], anSrcWin[3],
0, 0, nOXSize, nOYSize);
/* -------------------------------------------------------------------- */
/* In case of color table translate, we only set the color */
/* interpretation other info copied by CopyBandInfo are */
/* not relevant in RGB expansion. */
/* -------------------------------------------------------------------- */
if (nRGBExpand == 1)
{
poVRTBand->SetColorInterpretation(GCI_GrayIndex);
}