gdal java api 中文_GDAL_API教程.doc

GDAL_API教程GDAL_API教程

GDAL API Tutorial

Before opening a GDAL supported raster datastore it is necessary to register drivers.

在打开一个GDAL支持的栅格资料之前,必需要注册驱动。

There is a driver for each supported format.

每个驱动对应各自支持的格式。

Normally this is accomplished with the GDALAllRegister() function which attempts to register all known drivers, including those auto-loaded from .so files using GDALDriverManager::AutoLoadDrivers().

通常这个会被GDALAllRegister()函数完成,试图去注册所有已知的驱动包括使用GDALDriverManager::AutoLoadDrivers()从.so文件来加载。

If for some applications it is necessary to limit the set of drivers it may be helpful to review the code from gdalallregister.cpp.

如果一些程序有必要去限制驱动集合,检查gdalallregister.cpp的代码将会有所帮助,

Python automatically calls GDALAllRegister() when the gdal module is imported.

当gdal模块被导入时,Python会自动调用GDALAllRegister()。

Once the drivers are registered, the application should call the free standing GDALOpen() function to open a dataset, passing the name of the dataset and the access desired (GA_ReadOnly or GA_Update).

一但驱动被注册,程序将会调用独立的GDALOpen()函数通过dataset的名称和需要的存取方式(GA_ReadOnly或GA_Update)来打开dataset.

#include "gdal_priv.h"

int main()

{

GDALDataset *poDataset;

GDALAllRegister();

poDataset = (GDALDataset *) GDALOpen( pszFilename, GA_ReadOnly );

if( poDataset == NULL )

{

...;

}

Note that if GDALOpen() returns NULL it means the open failed, and that an error messages will already have been emitted via CPLError().

注意 如果GDALOpen()返回NULL,意味着打开失败了,这个错误信息将会通过CPLError()释放出。

If you want to control how errors are reported to the user review the CPLError() documentation.

如果你想控制错误怎样被报告给用户,参考CPLError文档。

Generally speaking all of GDAL uses CPLError() for error reporting.

一般而言,所有的GDAL都是用CPLError()来报告错误。

Also, note that pszFilename need not actually be the name of a physical file (though it usually is).

同样,注意pszFilename 不需要确实是物理文件名称(尽管通常都是如此)。

It's interpretation is driver dependent, and it might be an URL, a filename with additional parameters added at the end controlling the open

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
GDAL开发手册API详细说明,内含详细示例代码,适合初学者使用,非常棒的入门书!In pythe Import go from gdalconst import s datasct-gdal. Open( filename, GA ReadOnly if dataset is none 如果 GDALOpen(函数返回NUL则表示打开失败,同时 CPLError(函数产生 相应的错误信息。如果您需要对错误迂行处理可以参考 CPLError相关文档 通常情况下,所有的GDAL函数都通过 CPLError(报告错误。另外需要注意的 是 pszFilename并不一定对应一个实际的文件名(当然也可以就是一个文件 名)。它的具休解释由相应的驱动程序负责。它可能是一个URL,或者是文件 名以后后面带有许多用于控制打开方式的参数。通常建议,不要在打开文件的 选择对话框中对文件的类型做太多的限制。 1.2.获取 Dataset信息 如果GL数据模型一节所描述的,一个 GDALDataset包含了光栅数据的一系列 的泼段信息。同时它还包含元数据、一个坐标系统、投影类型、光枥的大小以 及其他许多信息。 dfGeotransform[0]/米左上角x*/ dfGeoTrans lori[1]/东西方向一个像素对应的距离*/ adfGeotransform[2]/米旋转,0表示上面为北方 adfGeotransform[3]米左上角y*/ adfGeotrans form[4]/*旋转,0表示上面为北方米/ adfGeoTransform[5]/*南北方向一个像素对应的距离*/ 如果需要输出 dataset的基木信息,可以这样: In c+t adfGcotransform[6] printf( Driver: %s/%s\n poDataset->GetDriver(->GetDescription o poDataset->GetDriver()->GetMetadataltem( GDAL DMD LONGNAME)) printr( Size is %dx%dx%d\n poDataset->GetRasterXSizeo, poDataset->GetRasterYSize( poDataset->GetRasterCounto) if( poDataset->GetProjectionRef(!= NULL printf( Projection is %s'n poDataset->GetProjectionRef() if( poDataset->GetGeoTransform( adfGeoTransform one printf( Origin=(%. 6f, %. 6f)\n adfGeoTransform[01, adfGeoTrans form[3]) printf(Pixel Size=(%. 6f, %. 6f)\n adfGcoTransform[1, adfGco Transform[5 In c GDALDriverh dRiver double adfGeoTransform[6] hDriver- GDALGctDatasctDriver( hDatasct printf( Driver: %s /%s\n GDALGetDriver ShortName( hDriver GDALGetDriverlongName ( dRiver)) printf size is %dx%dx%d\n GDALGetRasterXSize( hDataset GDALGetRasterYSize( dAtaset GDALGetRasterCount( hDataset)) if( GDALGetProjectionRef( hDataset )! -NULL printf( Projection is %s\n GDALGetProjectionRef( dAtaset )) if( GDALGetGeoTransform( hDataset, adfGeoTransform )==CE None printf( Origin =(9%.6f, %.6f)\n adfGeo Transform[01, adfGeo Transform[3]) printf( pixel Size=(%. 6f, %.6f)\n adfGeoTransform[1, adfGeoTrans form[5) In Python print Driver:', dataset GetDriver(. ShortName, /', dataset. Get Driver(. Lon

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值