ogr2ogr
Convert vector geospatial data between formats
TLDR
SYNOPSIS
ogr2ogr [options] dstdatasource srcdatasource [layer]
DESCRIPTION
ogr2ogr converts vector geospatial data between file formats, databases, and web services. It is part of the GDAL/OGR library and supports over 80 vector formats including Shapefile, GeoJSON, GeoPackage, PostGIS, KML, and GML.Beyond simple format conversion, ogr2ogr can reproject coordinates between spatial reference systems, filter features by attribute or spatial extent, select specific fields, and transform geometry types.
PARAMETERS
DSTDATASOURCE_
Destination dataset (file path, database connection string, etc.).SRCDATASOURCE_
Source dataset.-f FORMAT
Output format name (e.g., "GeoJSON", "ESRI Shapefile", "PostgreSQL", "GPKG").-t_srs SRS
Target spatial reference system (e.g., EPSG:4326).-s_srs SRS
Source spatial reference system (override if not defined in source).-select FIELDS
Comma-separated list of fields to copy from the source.-where EXPR
SQL WHERE clause to filter features from the source.-sql STATEMENT
SQL statement to execute against the source for feature selection.-overwrite
Delete and recreate the output layer if it already exists.-append
Append to an existing layer instead of creating a new one.-update
Open existing output datasource in update mode.-nln NAME
Assign a new name to the output layer.-nlt TYPE
Define the geometry type for the output layer.
CAVEATS
Part of the GDAL suite and must be installed separately. Format support depends on how GDAL was compiled. Coordinate system reprojection requires correct SRS definitions. Large datasets may require significant memory.
SEE ALSO
ogrinfo(1), gdal_translate(1), gdalwarp(1)
