ESRI个人地理数据库

司机简称

PGeo

生成依赖项

ODBC库

OGR可选地支持通过ODBC读取ESRI Personal GeoDatabase.mdb文件。Personal GeoDatabase是一个Microsoft Access数据库,其中包含一组由ESRI定义的用于保存GeoDatabase元数据的表,以及以自定义格式(基本上是Shapefile geometry片段)保存在BLOB列中的要素的几何图形。这个驱动程序通过ODBC访问个人地理数据库,但不依赖于任何ESRI中间件。

通过传递要访问的.mdb文件的文件名作为数据源名称,可以访问个人地理数据库。

In order to facilitate compatibility with different configurations, the PGEO_DRIVER_TEMPLATE config Option was added to provide a way to programmatically set the DSN programmatically with the filename as an argument. In cases where the driver name is known, this allows for the construction of the DSN based on that information in a manner similar to the default (used for Windows access to the Microsoft Access Driver).

OGR treats all feature tables as layers. Most geometry types should be supported, including 3D data. Measure information (m value) is also supported. Coordinate system information should be properly associated with layers.

目前,OGR个人Geodatabase驱动程序没有利用空间索引进行快速的空间查询,尽管将来可能会添加空间索引。

The Personal GeoDatabase format does not strictly differentiate between multi and single geometry types for polygon or line layers, and it is possible for a polygon or line layer to contain a mix of both single and multi type geometries. Accordingly, in order to provide predictable geometry types, the GDAL driver will always report the type of a line layer as wkbMultiLineString, and a polygon layer as wkbMultiPolygon. Single-part line or polygon features in the database will be promoted to multilinestrings or multipolygons during reading.

默认情况下,SQL语句直接传递给MDB数据库引擎。也可以请求驱动程序使用 OGR SQL 发动机,通过 “OGRSQL” ExecuteSQL()方法的字符串,作为SQL方言的名称。

特殊SQL请求

"GetLayerDefinition a_layer_name" and "GetLayerMetadata a_layer_name" can be used as special SQL requests to get respectively the definition and metadata of a Personal GeoDatabase table as XML content.

数据集打开选项

  • LIST_ALL_TABLES=YES/NO: This may be "YES" to force all tables, including system and internal tables (such as the GDB_* tables) to be listed (since GDAL 3.4)

驱动程序功能

Supports Georeferencing

This driver supports georeferencing

Field domains

3.4 新版功能.

Coded and range field domains are supported.

如何将PGeo驱动程序与unixODBC和MDB工具一起使用(在Unix和Linux上)

本文详细介绍了如何在unixODBC包中使用OGR,以及如何使用PGeo驱动程序访问个人地理数据库。另见 GDAL wiki for other details

先决条件

  1. 安装 unixODBC >=2.2.11条

  2. Install MDB Tools. The official upstream of MDB Tools is maintained at https://github.com/mdbtools/mdbtools Version 0.9.4 or later is recommended for best compatibility with the PGeo driver. With the latest version no additional configuration (the followings) is required on Debian Linux and ogrinfo sample.mdb works fine.

(On Ubuntu : sudo apt-get install unixodbc libmdbodbc)

(On Debian : sudo apt-get install unixodbc odbc-mdbtools)

配置

unixODBC有两个配置文件:

  • odbcinst.ini-此文件包含可供所有用户使用的ODBC驱动程序的定义;如果您自己构建unixODBC,则可以在/etc目录或指定为--sysconfdir的位置找到此文件。

  • odbc.ini-此文件包含对所有用户可用的odbc数据源(DSN项)的定义。

  • ~/.odbc.ini-这是用户可以放置自己的odbc数据源的专用文件。

编辑odbc.ini文件仅当您要设置ODBC数据源名称(DSN)以便可以通过DSN直接访问个人地理数据库文件时,才需要文件。这是完全可选的,因为如果使用direct.mdb文件名,PGeo驱动程序将自动为您处理所需的连接参数。

配置文件的格式非常简单:

[section_name]
entry1 = value
entry2 = value

有关详细信息,请参阅 unixODBC manual .

一。ODBC驱动程序配置

首先,需要配置ODBC驱动程序以使用MDB工具访问Microsoft access数据库。将以下定义添加到odbcinst.ini文件中。

[Microsoft Access Driver (*.mdb)]
Description = MDB Tools ODBC drivers
Driver     = /usr/lib/libmdbodbc.so.0
Setup      =
FileUsage  = 1
CPTimeout  =
CPReuse    =
  • [Microsoft Access Driver (*.mdb)] -记住使用“Microsoft Access驱动程序( * .mdb)“作为节的名称,因为PGeo驱动程序使用”driver=Microsoft Access driver“组成个人地理数据库的ODBC连接字符串( * .mdb);“字符串。

  • 描述-简短描述此驱动程序定义。

  • 驱动程序-MDB工具的ODBC驱动程序的完整路径。

2ODBC数据源配置(可选)

在本节中,我使用“sample.mdb”作为个人地理数据库的名称,因此请将此名称替换为您自己的数据库。

在主目录中创建.odbc.ini文件:

$ touch ~/.odbc.ini

将以下ODBC数据源定义放入.ODBC.ini文件:

[sample_pgeo]
Description = Sample PGeo Database
Driver      = Microsoft Access Driver (*.mdb)
Database    = /home/mloskot/data/sample.mdb
Host        = localhost
Port        = 1360
User        = mloskot
Password    =
Trace       = Yes
TraceFile   = /home/mloskot/odbc.log

DSN条目的逐步说明:

  • [sample_pgeo] -这是ODBC数据源(DSN)的名称。您将使用此名称引用您的个人地理数据库。你可以用你自己的名字。

  • Description—DSN项的简短描述。

  • Driver—在步骤1中定义的驱动程序的全名。上面。

  • 数据库-个人地理数据库的.mdb文件的完整路径。

  • MDB工具驱动程序不使用主机、端口、用户和密码项。

用ogrinfo测试PGeo驱动程序

现在,您可以尝试使用ogrinfo访问PGeo数据源。

首先,检查您是否在OGR中内置了PGeo驱动程序:

$ ogrinfo --formats
Supported Formats:
  ESRI Shapefile
  ...
  PGeo
  ...

现在,您可以访问您的个人地理数据库。如果您已为个人地理数据库设置了DSN(如上文第2节所述),则数据源应为PGeo:<DSN>,其中<DSN>是您放入数据库的DSN条目的名称。odbc.ini文件.

或者,可以将.mdb文件名直接传递给OGR,以避免手动创建DSN。

ogrinfo PGeo:sample_pgeo
INFO: Open of `PGeo:sample_pgeo'
using driver `PGeo' successful.
1. ...

运行上述命令后,您应该获得存储在geodatabase中的图层列表。

现在,您可以尝试查询特定层的详细信息:

ogrinfo PGeo:sample_pgeo <layer name>
INFO: Open of `PGeo:sample_pgeo'
using driver `PGeo' successful.

Layer name: ...

资源