GDAL打开ESRI FileGDB格式数据
通过gdal打开ArcGIS的File GeoDatabase数据格式,并显示属性。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 57344 2018-10-02 13:10 GDALTest01.vsGDALTest01v15.suo
文件 0 2018-10-02 08:24 GDALTest01.vsGDALTest01v15Serversqlite3db.lock
文件 598016 2018-10-02 12:52 GDALTest01.vsGDALTest01v15Serversqlite3storage.ide
文件 32768 2018-10-02 11:39 GDALTest01.vsGDALTest01v15Serversqlite3storage.ide-shm
文件 4120032 2018-10-02 13:10 GDALTest01.vsGDALTest01v15Serversqlite3storage.ide-wal
文件 187 2018-10-02 08:23 GDALTest01GDALTest01App.config
文件 2284544 2018-08-30 00:45 GDALTest01GDALTest01inDebugcairo.dll
文件 1043456 2017-09-03 16:15 GDALTest01GDALTest01inDebugcfitsio.dll
文件 111104 2018-08-30 00:45 GDALTest01GDALTest01inDebugexpat.dll
文件 9428976 2017-07-26 11:01 GDALTest01GDALTest01inDebugFileGDBAPI.dll
文件 58368 2018-08-30 00:45 GDALTest01GDALTest01inDebugfreexl.dll
文件 117760 2018-08-30 00:45 GDALTest01GDALTest01inDebugfribidi.dll
文件 16848384 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdal203.dll
文件 19968 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdalconst_csharp.dll
文件 16384 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdalconst_wrap.dll
文件 11264 2018-10-02 13:05 GDALTest01GDALTest01inDebugGDALTest01.exe
文件 187 2018-10-02 08:23 GDALTest01GDALTest01inDebugGDALTest01.exe.config
文件 30208 2018-10-02 13:05 GDALTest01GDALTest01inDebugGDALTest01.pdb
文件 97280 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdal_csharp.dll
文件 80896 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdal_wrap.dll
文件 1012224 2018-08-30 00:45 GDALTest01GDALTest01inDebuggeos.dll
文件 227840 2018-08-30 00:45 GDALTest01GDALTest01inDebuggeos_c.dll
文件 2108928 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5.dll
文件 235520 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5_cpp.dll
文件 97792 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5_hl.dll
文件 10240 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5_hl_cpp.dll
文件 546816 2017-09-03 18:05 GDALTest01GDALTest01inDebughdfdll.dll
文件 900608 2018-08-30 00:45 GDALTest01GDALTest01inDebugiconv.dll
文件 291840 2018-08-30 00:45 GDALTest01GDALTest01inDebuglibcurl.dll
文件 1175552 2018-08-30 00:45 GDALTest01GDALTest01inDebuglibeay32.dll
............此处省略93个文件信息
using OSGeo.OGR;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GDALTest01
{
public partial class Form1 : Form
{
private OSGeo.OGR.DataSource poDS = null;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender EventArgs e)
{
// 为了支持中文路径,请添加下面这句代码
OSGeo.GDAL.Gdal.SetConfigOption(“GDAL_FILENAME_IS_UTF8“ “NO“);
OSGeo.GDAL.Gdal.SetConfigOption(“PGEO_DRIVER_TEMPLATE“ “DRIVER=Microsoft Access Driver (*.mdb *.accdb);DBQ=%s“);
OSGeo.GDAL.Gdal.SetConfigOption(“MDB_DRIVER_TEMPLATE“ “DRIVER=Microsoft Access Driver (*.mdb *.accdb);DBQ=%s“);
// 为了使属性表字段支持中文,请添加下面这句
OSGeo.GDAL.Gdal.SetConfigOption(“SHAPE_ENCODING“ ““);
string strVectorFile = @“D: est.gdb“;
// 注册所有的驱动
Ogr.RegisterAll();
//创建数据,这里以创建ESRI的shp文件为例
string strDriverName = “OpenFileGDB“;
Driver oDriver = Ogr.GetDriverByName(strDriverName);
if (oDriver == null)
MessageBox.Show(“Driver Error“);
if (System.Environment.GetEnvironmentVariable(“GDAL_DATA“) == null)
System.Environment.SetEnvironmentVariable(“GDAL_DATA“ Application.StartupPath + “\gdal-data“);
if (System.Environment.GetEnvironmentVariable(“GEOTIFF_CSV“) == null)
System.Environment.SetEnvironmentVariable(“GEOTIFF_CSV“ Application.StartupPath + “\gdal-data“);
if (System.Environment.GetEnvironmentVariable(“GDAL_DRIVER_PATH“) == null)
System.Environment.SetEnvironmentVariable(“GDAL_DRIVER_PATH“ Application.StartupPath + “\gdalplugins“);
oDriver.Register();
poDS = oDriver.Open(strVectorFile 0);
if (poDS == null)
MessageBox.Show(“DataSource Creation Error“);
for (int i = 0; i < poDS.GetlayerCount(); i++)
{
layer layer = poDS.GetlayerByIndex(i);
listBox1.Items.Add(layer.GetName());
}
}
private void listBox1_SelectedIndexChanged(object sender EventArgs e)
{
if(poDS != null)
{
layer layer = poDS.GetlayerByName(listBox1.SelectedItem.ToString());
FeatureDefn featDefn = layer.GetlayerDefn();
int pFieldsCount = featDefn.GetFieldCount();
listView1.Columns.Clear();
for (int i = 0; i < pFieldsCount; i++)
{
listView1.Columns.Add(featDefn.GetFieldDefn(i).GetName());
}
layer.ResetReading();
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 57344 2018-10-02 13:10 GDALTest01.vsGDALTest01v15.suo
文件 0 2018-10-02 08:24 GDALTest01.vsGDALTest01v15Serversqlite3db.lock
文件 598016 2018-10-02 12:52 GDALTest01.vsGDALTest01v15Serversqlite3storage.ide
文件 32768 2018-10-02 11:39 GDALTest01.vsGDALTest01v15Serversqlite3storage.ide-shm
文件 4120032 2018-10-02 13:10 GDALTest01.vsGDALTest01v15Serversqlite3storage.ide-wal
文件 187 2018-10-02 08:23 GDALTest01GDALTest01App.config
文件 2284544 2018-08-30 00:45 GDALTest01GDALTest01inDebugcairo.dll
文件 1043456 2017-09-03 16:15 GDALTest01GDALTest01inDebugcfitsio.dll
文件 111104 2018-08-30 00:45 GDALTest01GDALTest01inDebugexpat.dll
文件 9428976 2017-07-26 11:01 GDALTest01GDALTest01inDebugFileGDBAPI.dll
文件 58368 2018-08-30 00:45 GDALTest01GDALTest01inDebugfreexl.dll
文件 117760 2018-08-30 00:45 GDALTest01GDALTest01inDebugfribidi.dll
文件 16848384 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdal203.dll
文件 19968 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdalconst_csharp.dll
文件 16384 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdalconst_wrap.dll
文件 11264 2018-10-02 13:05 GDALTest01GDALTest01inDebugGDALTest01.exe
文件 187 2018-10-02 08:23 GDALTest01GDALTest01inDebugGDALTest01.exe.config
文件 30208 2018-10-02 13:05 GDALTest01GDALTest01inDebugGDALTest01.pdb
文件 97280 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdal_csharp.dll
文件 80896 2018-08-30 00:45 GDALTest01GDALTest01inDebuggdal_wrap.dll
文件 1012224 2018-08-30 00:45 GDALTest01GDALTest01inDebuggeos.dll
文件 227840 2018-08-30 00:45 GDALTest01GDALTest01inDebuggeos_c.dll
文件 2108928 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5.dll
文件 235520 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5_cpp.dll
文件 97792 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5_hl.dll
文件 10240 2017-09-03 18:00 GDALTest01GDALTest01inDebughdf5_hl_cpp.dll
文件 546816 2017-09-03 18:05 GDALTest01GDALTest01inDebughdfdll.dll
文件 900608 2018-08-30 00:45 GDALTest01GDALTest01inDebugiconv.dll
文件 291840 2018-08-30 00:45 GDALTest01GDALTest01inDebuglibcurl.dll
文件 1175552 2018-08-30 00:45 GDALTest01GDALTest01inDebuglibeay32.dll
............此处省略93个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)