ogr_fdw
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
ogr_fdw | 1.1.9 | GIS | MIT | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1550 | ogr_fdw | No | Yes | No | Yes | No | Yes | - |
| Related | postgis file_fdw postgres_fdw postgis_topology postgis_raster postgis_sfcgal postgis_tiger_geocoder address_standardizer |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 1.1.9 | 1817161514 | ogr_fdw | - |
| RPM | PGDG | 1.1.9 | 1817161514 | ogr_fdw_$v | - |
| DEB | PGDG | 1.1.9 | 1817161514 | postgresql-$v-ogr-fdw | - |
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, optionalformat,updateable,config_options,open_options, andcharacter_encoding. - Table options:
layeridentifies the OGR layer andupdateablecan disable writes. fididentifies a feature and is required for writable foreign tables.ogr_fdw_infolists 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.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.