Linux command
ogrinfo 命令
文件
复制后可按需替换文件名、目录或参数。
常用示例
List layers and summary of a data source
ogrinfo [file.shp]
Summary of a specific layer only (no features)
ogrinfo -so [file.shp] [layer_name]
Dump all layers and all features
ogrinfo -al [file.shp]
Show a single feature by FID
ogrinfo [file.shp] [layer_name] -fid [feature_id]
Filter features with a WHERE clause
ogrinfo -al -where "[field = 'value']" [file.shp]
Run an SQL query
ogrinfo [file.shp] -sql "[SELECT * FROM layer]"
Output as JSON
ogrinfo -json [file.shp]
说明
ogrinfo lists information about an OGR-supported vector data source to stdout. It reports layers, schema, coordinate reference system, extents, feature counts, and optionally the features themselves. By executing SQL statements via -sql it can also edit data in supported drivers.
参数
- -al
- List all features of all layers (opposite of -so).
- -so
- Summary only: omit feature-by-feature reporting.
- -fl
- Enable listing of features (opposite of -so).
- -json
- Output the report in JSON format.
- -fid _ID_
- Only report the feature with the given FID.
- -sql _STATEMENT_
- Execute an SQL statement and return the result. Can also be a @filename reference.
- -dialect _DIALECT_
- SQL dialect to use (e.g., OGRSQL, SQLITE).
- -where _QUERY_
- Attribute filter applied to each layer.
- -spat _xmin_ _ymin_ _xmax_ _ymax_
- Spatial filter: only features intersecting this bounding box are reported.
- -geom _{YES|NO|SUMMARY|WKT|ISO_WKT}_
- How geometry is reported (default: YES).
- -limit _N_
- Limit the number of features per layer.
- -if _FORMAT_
- Force a specific driver when opening the input.
- -oo _NAME=VALUE_
- Pass a dataset open option to the driver.
- -ro
- Open the data source in read-only mode.
- -nomd
- Suppress metadata printing.
- -listmdd
- List all metadata domains available for the dataset.
- -mdd _domain_
- Report metadata for the specified domain.
- --help
- Display help information.
FAQ
What is the ogrinfo command used for?
ogrinfo lists information about an OGR-supported vector data source to stdout. It reports layers, schema, coordinate reference system, extents, feature counts, and optionally the features themselves. By executing SQL statements via -sql it can also edit data in supported drivers.
How do I run a basic ogrinfo example?
Run `ogrinfo [file.shp]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -al do in ogrinfo?
List all features of all layers (opposite of -so).