这段时间用GDAL的一些记录。肯定不完整,哈哈哈哈。
这段时间主要使用了GDAL的几个类:
GDALDataset, GDALRasterBand, GDALDriver
1. GDAL简介
2. GDAL读文件(C++)
#include "gdal_priv.h"
#include "cpl_conv.h" // for CPLMalloc()
int main()
{
GDALDataset *poDataset;
GDALAllRegister();
poDataset = (GDALDataset *)GDALOpen(pszFilename, GA_ReadOnly );
if( poDataset == NULL )
{
return 0 ;
}
...
}
- 首先看下GDAL的数据模型(GDAL DATA MODEL)
A dataset (represented by the GDALDataset class) is an assembly of related raster bands and some information common to them all. In particular the dataset has a concept of the raster size (in pixels and lines) that applies to all the bands. The dataset is also responsible for the georeferencing transform and coordinate system definition of all bands. The dataset itself can also have associated metadata, a list of name/value pairs in string form.
GDALALLRegister()
GDALAllRegister() 是注册所有GDAL的驱动,也就是说注册GDAL所支持的所有格式。
GDALOpen
GDALOpen函数原型为
//——————————————————
//GDALOpen : Open a raster file as a GDALDataset.
//pszFilename为文件路径
//GDALAccess为枚举类型,包含两个值{GA_ReadOnly, GA_Update}
//GA_ReadOnly为只读,GA_Update会更新原始数据
//——————————————————
GDALDatasetH GDALOpen( const char * pszFilename,
GDALAccess eAccess
)
一些GDALDataset的常用接口:
// 获得图像的格式信息
GDALDriver* GDALDataset::GetDriver( void )
/