GDAL_API教程

GDAL_API教程

ID:37917911

大小:182.50 KB

页数:22页

时间:2019-06-02

GDAL_API教程_第1页
GDAL_API教程_第2页
GDAL_API教程_第3页
GDAL_API教程_第4页
GDAL_API教程_第5页
资源描述:

《GDAL_API教程》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、GDALAPITutorialBeforeopeningaGDALsupportedrasterdatastoreitisnecessarytoregisterdrivers.在打开一个GDAL支持的栅格资料之前,必需要注册驱动。Thereisadriverforeachsupportedformat.每个驱动对应各自支持的格式。NormallythisisaccomplishedwiththeGDALAllRegister()functionwhichattemptstoregisterallknowndrivers,includingthoseauto-loadedfrom.sofile

2、susingGDALDriverManager::AutoLoadDrivers().通常这个会被GDALAllRegister()函数完成,试图去注册所有已知的驱动包括使用GDALDriverManager::AutoLoadDrivers()从.so文件来加载。Ifforsomeapplicationsitisnecessarytolimitthesetofdriversitmaybehelpfultoreviewthecodefromgdalallregister.cpp.如果一些程序有必要去限制驱动集合,检查gdalallregister.cpp的代码将会有所帮助,Pythonaut

3、omaticallycallsGDALAllRegister()whenthegdalmoduleisimported.当gdal模块被导入时,Python会自动调用GDALAllRegister()。Oncethedriversareregistered,theapplicationshouldcallthefreestandingGDALOpen()functiontoopenadataset,passingthenameofthedatasetandtheaccessdesired(GA_ReadOnlyorGA_Update).一但驱动被注册,程序将会调用独立的GDALOpen()函

4、数通过dataset的名称和需要的存取方式(GA_ReadOnly或GA_Update)来打开dataset.#include"gdal_priv.h"intmain(){GDALDataset*poDataset;GDALAllRegister();poDataset=(GDALDataset*)GDALOpen(pszFilename,GA_ReadOnly);if(poDataset==NULL){...;}NotethatifGDALOpen()returnsNULLitmeanstheopenfailed,andthatanerrormessageswillalreadyhaveb

5、eenemittedviaCPLError().注意如果GDALOpen()返回NULL,意味着打开失败了,这个错误信息将会通过CPLError()释放出。IfyouwanttocontrolhowerrorsarereportedtotheuserreviewtheCPLError()documentation.如果你想控制错误怎样被报告给用户,参考CPLError文档。GenerallyspeakingallofGDALusesCPLError()forerrorreporting.一般而言,所有的GDAL都是用CPLError()来报告错误。Also,notethatpszFilena

6、meneednotactuallybethenameofaphysicalfile(thoughitusuallyis).同样,注意pszFilename不需要确实是物理文件名称(尽管通常都是如此)。It'sinterpretationisdriverdependent,anditmightbeanURL,afilenamewithadditionalparametersaddedattheendcontrollingtheopenoralmostanything.这个解释了驱动的依赖性,它可能是一个URL,带有加在最后的额外的参数的文件名,控制了打开或是其他行为。Pleasetrynott

7、olimitGDALfileselectiondialogstoonlyselectingphysicalfiles.请不要去限制GDAL文件选择对话框去仅仅选择物理文件。GettingDatasetInformationAsdescribedintheGDALDataModel,aGDALDatasetcontainsalistofrasterbands,allpertainingtothesamearea

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。