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 [--help] [-ro] [-q] [-where condition] [-sql statement] [-dialect dialect] [-fid fid] [-spat xmin ymin xmax ymax] [-geomfield field] [-fields {YES/NO}] [-summary] [-nocount] [-nogeomtype] [-noattr] [-nocoordinate] [-nomd] [-listlayers] [-oo NAME=VALUE] datasource_name [layername]
PARAMETERS
--help
Display help message.
-ro
Open in read-only mode.
-q
Suppress progress messages and other non-error output. Quiet mode.
-where condition
Attribute query (like SQL WHERE clause). Only features satisfying the provided condition are selected.
-sql statement
Execute SQL statement against the data source. Allows for complex queries.
-dialect dialect
SQL dialect to use. Usually 'OGRSQL' or 'SQLite'.
-fid fid
Report only the feature with the specified feature id.
-spat xmin ymin xmax ymax
Spatial filter (bounding box). Only features intersecting the box are selected.
-geomfield field
Name of the geometry field to use for spatial filtering. Default is usually 'geometry'.
-fields {YES/NO}
Only display field names. Defaults to YES.
-summary
Only display summary information for each feature class.
-nocount
Suppress feature count output.
-nogeomtype
Suppress geometry type output.
-noattr
Suppress attribute output.
-nocoordinate
Suppress coordinate output for each feature.
-nomd
Suppress metadata domain output.
-listlayers
List layers available in the data source and then exit.
-oo NAME=VALUE
Data source specific open option.
datasource_name
The path or connection string to the vector data source (e.g., a shapefile, a database connection string).
layername
Optional. The name of a specific layer to inspect. If omitted, information about all layers in the data source is displayed.
DESCRIPTION
The ogrinfo command is a command-line utility that provides detailed information about vector geospatial data sources supported by the OGR Simple Features Library. It allows users to inspect the contents of vector data files (e.g., shapefiles, GeoJSON, PostGIS databases) including layer names, feature counts, attribute schemas, spatial extents, coordinate reference systems, and other metadata.
ogrinfo is essential for understanding the structure and properties of geospatial data before using it in other geoprocessing tasks. It supports various data formats due to the underlying OGR library's extensive driver support. It is a crucial tool for geographers, GIS analysts, developers, and anyone working with spatial data in a command-line environment. The command is part of the GDAL/OGR Geospatial Data Abstraction Library suite, which provides a wide range of tools for working with geospatial data.
CAVEATS
OGR's driver support varies. Not all drivers support all features or options.
Performance can be slow on very large datasets, especially with complex queries.
EXAMPLES
Get summary information about all layers in a shapefile:
ogrinfo myshapefile.shp
Get information about a specific layer:
ogrinfo myshapefile.shp Buildings
Get information about a GeoJSON file using SQL:
ogrinfo -sql 'SELECT * FROM mygeojsonfile' mygeojsonfile.geojson
HISTORY
ogrinfo is a part of the GDAL/OGR library, which originated in the late 1990s as a tool for reading and writing geospatial data formats. It has been continuously developed and improved over the years, adding support for new formats, features, and optimizations. Its initial focus was on raster formats (GDAL), with vector support (OGR) being added later. The command has become a standard tool for geospatial data exploration and analysis.