If you have found a tutorial that includes a line like ogr2ogr -f GFT ... or links to http://www.gdal.org/ogr/drv_gft.html, the tutorial is dead. The GFT driver connected to Google Fusion Tables, which Google shut down on December 3, 2019. The gdal.org/ogr/drv_gft.html URL itself no longer resolves — the entire GDAL documentation was restructured and the GFT driver pages were not preserved. Links to it from GIS community sites still circulate and lead nowhere.

This post is the replacement. It covers the GDAL/OGR vector toolchain as it actually works in 2026: ogrinfo for inspection, ogr2ogr for conversion, and the options you will actually reach for. It does not cover raster (gdalinfo, gdal_translate, gdalwarp) — that is a separate tool family.

What GDAL and OGR are

GDAL (Geospatial Data Abstraction Library) is the standard open-source library for reading and writing raster geospatial data. OGR is the vector half of the same project — the part that reads and writes Shapefile, GeoJSON, GeoPackage, KML, PostGIS, DXF, CSV, and over 200 other vector formats.

In practice: gdal_translate and gdalwarp are GDAL (raster); ogrinfo and ogr2ogr are OGR (vector). The project merged under the GDAL name in version 2.0, but the naming convention for the commands stayed the same.

GDAL/OGR is the underlying engine in QGIS, ArcGIS Pro, and most open-source GIS tools. When QGIS exports a Shapefile, it calls OGR. Using ogr2ogr directly is faster, scriptable, and does not require a desktop GIS.

Installation: conda install -c conda-forge gdal, brew install gdal (macOS), or apt install gdal-bin (Debian/Ubuntu). Check version with:

ogr2ogr --version
# GDAL 3.10.x, released 2025/xx/xx

ogrinfo — Inspect before you convert

Before converting a file, inspect it. ogrinfo shows you what is inside without modifying anything.

Check what formats OGR can read and write

ogr2ogr --formats

The output lists every driver with a r (read only) or rw (read-write) flag. If a format you expect is missing, the GDAL build on your machine may not include that driver — conda-forge builds tend to include more drivers than OS package manager builds.

Inspect a Shapefile

ogrinfo -so mydata.shp mydata

-so (summary only) prints the layer name, geometry type, feature count, spatial extent, coordinate reference system, and field schema without dumping all features. Drop -so to print every feature — useful for small files, overwhelming for anything larger.

ogrinfo -al -so roads.gpkg

-al lists all layers. For a GeoPackage with multiple layers, this shows each layer’s geometry type and field schema. Essential for files you received from an external source and do not fully know.

Check the CRS

ogrinfo -so -nomd admin_areas.geojson admin_areas | grep -A 20 "Layer SRS WKT"

GeoJSON is supposed to be in WGS84 (EPSG:4326) per RFC 7946. In practice, files from AutoCAD or non-standard sources often have no CRS set or have a wrong CRS that was carried through a lossy conversion. Confirming the CRS before conversion prevents silent reprojection errors.

ogr2ogr — Convert formats

Basic syntax

ogr2ogr -f "output_format" output_path input_path [layer_name]

The output format string must match the driver name exactly (case-sensitive on some platforms). Use ogr2ogr --formats to find the correct string. Common ones:

FormatDriver string
ESRI ShapefileESRI Shapefile
GeoPackageGPKG
GeoJSONGeoJSON
KMLKML
FlatGeobufFlatGeobuf
PostgreSQL/PostGISPostgreSQL
DXF (AutoCAD)DXF
CSV with geometryCSV

GeoJSON to Shapefile

ogr2ogr -f "ESRI Shapefile" output_dir/ input.geojson

Shapefile output requires a directory, not a single file path. ogr2ogr writes .shp, .shx, .dbf, and .prj as separate files. If the directory does not exist, ogr2ogr creates it.

Shapefile field name truncation: Shapefile limits attribute names to 10 characters. ogr2ogr truncates silently. If your GeoJSON has fields named population_density and population_description, both truncate to population_ — and the second field silently overwrites or gets a numeric suffix. The GeoJSON to Shapefile field truncation problem is the most common silent data loss in format conversion. Inspect the schema with ogrinfo after conversion.

If the input has fields you do not need, drop them before converting:

ogr2ogr -f "ESRI Shapefile" output_dir/ input.geojson -select "id,name,area_km2"

Shapefile to GeoPackage

GeoPackage is the practical replacement for Shapefile: single file, no field name limits, supports multiple geometry types and multiple layers, supports transactions.

ogr2ogr -f GPKG output.gpkg input.shp

To add a second layer to an existing GeoPackage:

ogr2ogr -f GPKG -update -append output.gpkg second_input.shp

KML to GeoJSON

ogr2ogr -f GeoJSON output.geojson input.kml

KML can contain points, lines, and polygons in the same file. OGR splits them into separate layers (Point, LineString, Polygon) by default. To merge all geometry types into one layer:

ogr2ogr -f GeoJSON output.geojson input.kml -nlt GEOMETRY

-nlt GEOMETRY (or -nlt GEOMETRYCOLLECTION) accepts mixed geometry. This is often what you want when KML was exported from Google Maps or ArcGIS Online and has mixed feature types.

Shapefile to GeoJSON with CRS reprojection

GeoJSON must use WGS84 geographic coordinates (EPSG:4326) per RFC 7946. If the source Shapefile is in a projected CRS (UTM, State Plane, OSGB36, etc.), reproject during conversion:

ogr2ogr -f GeoJSON -t_srs EPSG:4326 output.geojson input_utm.shp

-t_srs = target CRS. OGR reads the source CRS from the .prj file (or from the layer metadata for GeoPackage/PostGIS). If the .prj file is missing or wrong, add -s_srs to override:

ogr2ogr -f GeoJSON -s_srs EPSG:32617 -t_srs EPSG:4326 output.geojson input.shp

-s_srs EPSG:32617 = “treat the source as UTM zone 17N regardless of the .prj file.”

DXF to GeoPackage

OGR can read DXF files from AutoCAD and write them to georeferenced formats — but only if the DXF has real-world coordinates (i.e., was drawn at true scale in a projected CRS, not in paper units).

ogr2ogr -f GPKG output.gpkg input.dxf

If the DXF has no CRS metadata (AutoCAD DXF does not store CRS), assign one:

ogr2ogr -f GPKG -a_srs EPSG:32617 output.gpkg input.dxf

-a_srs assigns a CRS to the output without reprojecting. Use this when you know what CRS the DXF was drawn in but the file has no metadata for it. The CAD-GIS format gap post covers the full set of failures that occur when DXF files are exported at wrong scales or in paper units — ogr2ogr cannot fix those, only read correctly-built DXF.

Filtering with -where and -sql

Attribute filter

To convert only features matching a condition:

ogr2ogr -f GeoJSON output.geojson input.gpkg -where "population > 100000"

-where takes a SQL WHERE clause expression evaluated by OGR’s internal engine (no JOIN). Supported operators: =, <>, <, >, <=, >=, IN (...), LIKE, IS NULL, IS NOT NULL. String values need single quotes.

SQL query

For anything requiring grouping, computed columns, or joins between layers in the same file:

ogr2ogr -f GeoJSON output.geojson input.gpkg \
  -sql "SELECT name, area_km2 FROM admin_areas WHERE region = 'North' ORDER BY name"

With a GeoPackage or PostGIS source, you can also use proper SQL JOINs:

ogr2ogr -f GeoJSON output.geojson input.gpkg \
  -sql "SELECT a.name, p.population FROM areas a JOIN population p ON a.id = p.area_id"

Spatial filter

To convert only features intersecting a bounding box:

ogr2ogr -f GeoJSON output.geojson input.shp -spat xmin ymin xmax ymax

Coordinates in the source CRS. For WGS84: -spat -77.5 38.8 -76.9 39.0 (Washington DC area).

Layer creation options (-lco)

-lco (layer creation options) passes driver-specific flags. The available flags differ by driver — check ogr2ogr --help or the format’s documentation page at gdal.org/en/stable/drivers/vector/.

Useful -lco flags for Shapefile:

# Force UTF-8 encoding in the .dbf file (avoids encoding corruption)
ogr2ogr -f "ESRI Shapefile" output_dir/ input.geojson -lco ENCODING=UTF-8

For GeoJSON:

# Limit decimal precision to 6 places (reduces file size significantly)
ogr2ogr -f GeoJSON output.geojson input.shp -lco COORDINATE_PRECISION=6

For GeoPackage:

# Set spatial index (built by default; disable for write speed during batch import)
ogr2ogr -f GPKG output.gpkg input.shp -lco SPATIAL_INDEX=NO

Batch conversion with Python

For converting a directory of Shapefiles:

import subprocess
from pathlib import Path

src_dir = Path("input/")
dst_dir = Path("output/")
dst_dir.mkdir(exist_ok=True)

for shp in src_dir.glob("*.shp"):
    out = dst_dir / (shp.stem + ".geojson")
    subprocess.run([
        "ogr2ogr",
        "-f", "GeoJSON",
        "-t_srs", "EPSG:4326",
        str(out),
        str(shp)
    ], check=True)
    print(f"Converted {shp.name}")

check=True raises subprocess.CalledProcessError if ogr2ogr exits non-zero. By default, ogr2ogr returns 0 on success and non-zero on failure, but some warnings still produce exit code 0. If you need stricter validation, run ogrinfo -so on the output and check feature count against the source.

For a PostGIS target (bulk loading multiple Shapefiles into one database):

pg_conn = "PG:host=localhost dbname=gisdb user=gisadmin"

for shp in src_dir.glob("*.shp"):
    subprocess.run([
        "ogr2ogr",
        "-f", "PostgreSQL",
        pg_conn,
        str(shp),
        "-nln", shp.stem.lower(),   # table name = filename
        "-overwrite",
        "--config", "PG_USE_COPY", "YES"   # bulk load instead of INSERT
    ], check=True)

PG_USE_COPY YES switches from individual INSERT statements to PostgreSQL’s COPY bulk loader — typically 10-30x faster for large datasets.

Known gotchas

GDAL 3.8+ Arrow API: GDAL 3.8 introduced an Arrow-based internal API for vector I/O that is faster but occasionally produces unexpected errors on certain driver combinations. If you hit errors that do not reproduce on GDAL 3.7, add:

ogr2ogr --config OGR2OGR_USE_ARROW_API NO ...

This reverts to the classic algorithm and is safe to use permanently.

GFT driver is gone: Any script or tutorial referencing ogr2ogr -f GFT or the driver string Google Fusion Tables will fail with “Unable to find driver GFT”. Google Fusion Tables shut down in December 2019. The old GDAL documentation page at http://www.gdal.org/ogr/drv_gft.html is a hard 404. If you have Fusion Tables data to migrate, export it to CSV from the Wayback Machine (if archived) or use the Google Takeout archive format, then convert with -f GeoJSON from CSV with geometry columns.

Shapefile vs GeoPackage for working data: Shapefile is the exchange format your suppliers send you; GeoPackage is what you should work in. The free and open-source GIS tools comparison covers the format decision in more detail, including which formats ArcGIS, QGIS, and Global Mapper each handle best.

Silent geometry drops on Shapefile output: If the source has mixed geometry types (points + polygons in the same layer), Shapefile output will silently drop all features except the first geometry type encountered unless you specify -nlt. Check feature counts after conversion. The GIS file conversion silent failures post details this and four other common cases.

Using GeoConvert for one-off conversions

ogr2ogr has a learning curve. For a single GeoJSON-to-Shapefile conversion without installing GDAL, GeoConvert handles it in a browser: upload the GeoJSON, get back a .zip with the four Shapefile components. The underlying engine is GDAL, so the output is equivalent to what ogr2ogr produces. It handles CRS detection, geometry validation, and RFC 7946 attribute mapping automatically.

For production pipelines that run on a schedule, scripted batch jobs, or large files above 100MB, ogr2ogr directly is the right tool.

Further reading

The current GDAL documentation is at gdal.org/en/stable/programs/ogr2ogr.html — note the /en/stable/ path, not the old /ogr/ path. The FME alternatives post covers where ogr2ogr fits against PDAL and QGIS Graphical Modeler for teams migrating off Safe Software FME.