ogr_fdw

foreign-data wrapper for GIS data access

Overview

PackageVersionCategoryLicenseLanguage
ogr_fdw1.1.9GISMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
1550ogr_fdwNoYesNoYesNoYes-
Relatedpostgis file_fdw postgres_fdw postgis_topology postgis_raster postgis_sfcgal postgis_tiger_geocoder address_standardizer

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG1.1.91817161514ogr_fdw-
RPMPGDG1.1.91817161514ogr_fdw_$v-
DEBPGDG1.1.91817161514postgresql-$v-ogr-fdw-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64
u26.x86_64
u26.aarch64

Install

You can install ogr_fdw directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install ogr_fdw;          # Install for current active PG version
pig ext install -y ogr_fdw -v 18  # PG 18
pig ext install -y ogr_fdw -v 17  # PG 17
pig ext install -y ogr_fdw -v 16  # PG 16
pig ext install -y ogr_fdw -v 15  # PG 15
pig ext install -y ogr_fdw -v 14  # PG 14
dnf install -y ogr_fdw_18       # PG 18
dnf install -y ogr_fdw_17       # PG 17
dnf install -y ogr_fdw_16       # PG 16
dnf install -y ogr_fdw_15       # PG 15
dnf install -y ogr_fdw_14       # PG 14
apt install -y postgresql-18-ogr-fdw   # PG 18
apt install -y postgresql-17-ogr-fdw   # PG 17
apt install -y postgresql-16-ogr-fdw   # PG 16
apt install -y postgresql-15-ogr-fdw   # PG 15
apt install -y postgresql-14-ogr-fdw   # PG 14

Create Extension:

CREATE EXTENSION ogr_fdw;

Usage

Sources:

ogr_fdw exposes vector data supported by GDAL/OGR as PostgreSQL foreign tables. It can read files and remote data sources through OGR drivers and can write when the selected driver and data source support updates. Install PostGIS before ogr_fdw for native geometry columns; otherwise geometry is exposed as WKB bytea.

Discover and Import a Layer

Use the installed helper to inspect a source and generate matching SQL:

ogr_fdw_info -s /srv/gis/cities.gpkg
ogr_fdw_info -s /srv/gis/cities.gpkg -l cities

A minimal equivalent definition is:

CREATE EXTENSION postgis;
CREATE EXTENSION ogr_fdw;

CREATE SERVER city_source
  FOREIGN DATA WRAPPER ogr_fdw
  OPTIONS (
    datasource '/srv/gis/cities.gpkg',
    format 'GPKG'
  );

CREATE FOREIGN TABLE city (
  fid bigint,
  geom geometry,
  name text
) SERVER city_source
  OPTIONS (layer 'cities');

SELECT fid, name FROM city WHERE geom && ST_MakeEnvelope(-10, 35, 30, 60, 4326);

The PostgreSQL server account needs filesystem permissions for file-backed data sources and network/credential access for remote drivers.

Import and Mapping

CREATE SCHEMA gis_import;

IMPORT FOREIGN SCHEMA ogr_all
  LIMIT TO (cities)
  FROM SERVER city_source
  INTO gis_import;

ogr_all means all OGR layers. Import normally launders table and column names; use launder_table_names and launder_column_names options when exact remote names are required. A foreign column can map to a different source name with OPTIONS (column_name 'RemoteName').

Important Options and Objects

  • Server options: required datasource, optional format, updateable, config_options, open_options, and character_encoding.
  • Table options: layer identifies the OGR layer and updateable can disable writes.
  • fid identifies a feature and is required for writable foreign tables.
  • ogr_fdw_info lists drivers and layers and emits server/table definitions.
  • ogr_fdw_version() reports the extension and GDAL version.
  • ogr_fdw_drivers() lists the compiled OGR drivers.

Performance and Write Boundaries

Simple comparisons and bounding-box && predicates can be pushed down, but more complex filters may be evaluated locally. The FDW retrieves all selected source columns and opens two OGR connections per query rather than pooling them. Use EXPLAIN, project only needed columns, and benchmark the actual driver and data source.

Writes depend on driver capability and require source-level write permissions plus fid. Set updateable = false when a source must remain read-only. Version 1.1.9 simplifies the version string relative to 1.1.8 and has no documented SQL workflow change; the control file remains at SQL extension version 1.1.


Last Modified 2026-07-23: update extension list to 555 (d81fc56)