ogrinfo
Get information about vector geospatial data
TLDR
List supported formats
List layers of a data source
Get detailed information about a specific layer of a data source
Show summary information about a specific layer of a data source
Show summary of all layers of the data source
Show detailed information of features matching a condition
Update a layer in the data source with SQL
SYNOPSIS
ogrinfo [options] <datasource_name> [layer_name]
PARAMETERS
-ro
Open the data source in read-only mode.
-al
List all layers in the data source. This is the default if no layer_name is specified.
-so
Summary only. Suppresses the listing of individual features, showing only layer schema and statistics.
-json
Output the information in JSON format (GDAL 2.2+).
-sql
Execute an SQL query against the data source. The results are presented as a virtual layer.
-where
Apply an SQL WHERE clause to filter features from the selected layer.
-spat
Spatially filter features within the specified bounding box coordinates.
-fid
Select and display only the feature with the specified Feature ID (fid).
-geom
Control how geometry is displayed: YES (display WKT), NO (don't display), or SUMMARY (display type and extent).
-fields
Control how fields are displayed: YES (display all fields), NO (don't display).
-stats
Display statistics (min/max/mean/stddev) for numeric fields in the layer.
-nomd
Do not display metadata.
-listmd
List available metadata domains for the data source.
-mdd
Display metadata from a specific domain (e.g., 'IMAGERY_OVERVIEW').
-oo
Set a driver-specific open option for the data source. Can be used multiple times.
-gt
Group features. Stop after displaying the first count features.
-dialect
Set the SQL dialect to use (e.g., 'OGRSQL', 'SQLite').
DESCRIPTION
The ogrinfo command is a powerful utility within the GDAL/OGR library designed to inspect and report information about geospatial vector data sources and their layers. It supports a vast array of vector formats, including Shapefile, GeoJSON, KML, PostGIS, GPKG, and many more. Users can employ ogrinfo to list available drivers, identify layers within a data source, display detailed layer schema (fields, geometry type, spatial reference system), and even query or filter features based on SQL expressions or spatial extents.
It serves as a crucial diagnostic and exploration tool, allowing users to verify data integrity, understand projections, and explore attribute tables before performing more complex transformations with other GDAL/OGR utilities like ogr2ogr. Its flexibility and comprehensive reporting capabilities make it an indispensable asset in geospatial data analysis and processing workflows.
CAVEATS
Performance can be impacted by large datasets, complex queries, or extensive feature listing. The availability of specific features and supported formats depends on how the GDAL/OGR library was compiled and which drivers are installed. Memory usage can increase significantly when processing or filtering a very high number of features. Behavior of SQL options (-sql, -where) can vary based on the data source's underlying driver capabilities or the specified SQL dialect.
DEFAULT BEHAVIOR
When ogrinfo is invoked with only a datasource_name and no layer_name, it defaults to listing all available layers within that data source, providing a high-level overview of its contents.
DRIVER-SPECIFIC OPEN OPTIONS
The -oo option is critical for interacting with specific data source types. It allows users to pass format-specific configuration options, such as connection parameters for databases (e.g., 'DB_SCHEMA=public' for PostGIS) or specific file handling settings for complex formats. Consult the GDAL/OGR documentation for the specific driver to find applicable options.
HISTORY
ogrinfo is an integral part of the GDAL/OGR library, which began development in 1998. The OGR (OpenGIS Simple Features Reference Implementation) component, responsible for vector data handling, was introduced around 2001. Since its inception, ogrinfo has served as the primary command-line utility for inspecting vector datasets. Its evolution mirrors that of the GDAL/OGR project, consistently adding support for new data formats, incorporating advanced querying capabilities (like JSON output and improved SQL dialects), and enhancing performance, solidifying its role as a cornerstone tool for geospatial data interoperability.