GDAL-VECTOR-CHECK-GEOMETRY(1)

πŸ“¦
version 3.13.3 Β· 4 versions
, in alpine 3.24, arch rolling, ubuntu stonking

🌸 NAME 🌸

okay so this page is straight outta the GDAL manual β€” it's GDAL-VECTOR-CHECK-GEOMETRY(1) β€” and bestie, it's a baddie πŸ’…

gdal-vector-check-geometry β€” Check a dataset for invalid or non-simple geometries πŸ¦‹

Added in version 3.12. (yes she's new here and she ate)


✨ SYNOPSIS ✨

Usage: gdal vector check-geometry [OPTIONS] <INPUT> <OUTPUT>

Check a dataset for invalid geometries

Positional arguments:
  -i, --input <INPUT>                                  Input vector datasets [required] [not available in pipelines]
  -o, --output <OUTPUT>                                Output vector dataset [required] [not available in pipelines]

Common Options:
  -h, --help                                           Display help message and exit
  --json-usage                                         Display usage as JSON document and exit
  --config <KEY>=<VALUE>                               Configuration option [may be repeated]
  -q, --quiet                                          Quiet mode (no progress bar or warning message) [not available in pipelines]

Options:
  -l, --layer, --input-layer <INPUT-LAYER>             Input layer name(s) [may be repeated] [not available in pipelines]
  -f, --of, --format, --output-format <OUTPUT-FORMAT>  Output format ("GDALG" allowed) [not available in pipelines]
  --co, --creation-option <KEY>=<VALUE>                Creation option [may be repeated] [not available in pipelines]
  --lco, --layer-creation-option <KEY>=<VALUE>         Layer creation option [may be repeated] [not available in pipelines]
  --overwrite                                          Whether overwriting existing output dataset is allowed [not available in pipelines]
  --update                                             Whether to open existing dataset in update mode [not available in pipelines]
  --overwrite-layer                                    Whether overwriting existing output layer is allowed [not available in pipelines]
  --append                                             Whether appending to existing layer is allowed [not available in pipelines]
                                                       Mutually exclusive with --upsert
  --output-layer <OUTPUT-LAYER>                        Output layer name [not available in pipelines]
  --skip-errors                                        Skip errors when writing features [not available in pipelines]
  --no-create-empty-layers                             Avoid creating layers to which no features will be written [not available in pipelines]
  --include-field <INCLUDE-FIELD>                      Fields from input layer to include in output (special values: ALL and NONE) (default: NONE) [may be repeated]
  --include-valid                                      Include valid inputs in output, with empty geometry
  --geometry-field <GEOMETRY-FIELD>                    Name of geometry field to check

Advanced Options:
  --if, --input-format <INPUT-FORMAT>                  Input formats [may be repeated] [not available in pipelines]
  --oo, --open-option <KEY>=<VALUE>                    Open options [may be repeated] [not available in pipelines]
  --output-oo, --output-open-option <KEY>=<VALUE>      Output open options [may be repeated] [not available in pipelines]
  --upsert                                             Upsert features (implies 'append') [not available in pipelines]
                                                       Mutually exclusive with --append

πŸ’– DESCRIPTION πŸ’–

gdal vector check-geometry is the friend who goes through your dataset feature by feature and is like "girl… this one's not valid, and also not simple" 😭. It checks that individual elements of a dataset are valid and simple according to the OGC Simple Features standard. For each invalid or non-simple feature, it will output a description and, in most cases, a point location of the error. Receipts, always πŸ“

Here's what actually gets checked, and it depends on the input geometry type:

  • Polygons and MultiPolygons are checked for validity. A single point error point will be reported even if there are multiple causes of invalidity. (one point, one vibe, no essay)
  • LineStrings and MultiLineStrings are checked for simplicity. All self-intersection locations will be reported if GDAL is built using version 3.14 or later of the GEOS library. With earlier versions, self-intersection locations are not reported. so like, upgrade bestie 🫢
  • GeometryCollections are checked that their individual elements are valid / simple. A single error point will be reported even if there are multiple causes of invalidity.
  • Other geometry types are not checked. they're just vibing, unbothered, moisturized ✨

Validity/simplicity checking is performed by the GEOS library and should be consistent with results of software such as PostGIS, QGIS, and shapely that also use that library. GEOS does not consider repeated points to be a cause of invalidity or non-simplicity. For more information about validity testing performed by gdal vector check-geometry, and examples of reported errors, see Geometry Validity.

[image] Error locations reported by gdal vector check-geometry for Polygon, MultiPolyon, and LineString inputs. πŸ“Έ (yes we said MultiPolyon, that's the original's spelling, no cap, we don't touch it)

⚠️ WARNING: Curved geometries are linearized before converting to GEOS. Linearized geometries may be valid/simple where the original geometries are not, and vice-versa. πŸ’€ so like, don't trust it blindly, it's giving "different shape, different drama".

πŸŽ€ GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) πŸŽ€

This program supports serializing the command line as a JSON file using the GDALG output format. The resulting file can then be opened as a vector dataset using the GDALG: GDAL Streamed Algorithm driver, and apply the specified pipeline in a on-the-fly / streamed way. iconic behavior honestly πŸ‘‘

πŸ“ NOTE: However this algorithm is not natively streaming compatible. Consequently a in-memory temporary dataset will be generated, which may cause significant processing time at opening. 😭 she's doing her best but she's gotta load the whole thing first.

πŸ’… PROGRAM-SPECIFIC OPTIONS πŸ’…

  • --geometry-field β€” Specify the name of the geometry field to test, for layers having multiple geometry fields. By default the first geometry field will be used. (she picks for you if you don't pick πŸŽ€)
  • --include-field β€” Added in version 3.12.1. Optional field(s) to copy from the input features to the output. Since GDAL 3.13, the value ALL can be used to include all fields from the source layer.
  • --include-valid β€” Include features for valid/simple geometries in the output, maintaining 1:1 correspondence between input and output features. so nobody gets ghosted, everybody shows up to the output πŸ‘―β€β™€οΈ
  • --input-layer <INPUT-LAYER> β€” Specifies the name of one or more layers to process. By default, all layers will be processed. (she's an overachiever, she does the whole dataset unless you tell her not to)
  • --output-layer β€” Specifies the name of the layer to which features will be written. If not specified and there is a single input layer, the name "error_location" will be used. If not specified and there are multiple input layers, features for each input layer will be written to a separate output layer in the format "error_location_{INPUT_LAYER}". 🌈 one layer per input layer, organized queen behavior

✨ STANDARD OPTIONS ✨

These are the ones every <rainbow>gdal</rainbow> vector tool shares, so you probs already know the vibe β€” but let's go through them anyway, bestie. No skipping. πŸ’…

  • --append β€” Can we yeet new features into layer(s) that already exist? This says yes. Bonus: it also creates the output dataset for you if it's not there yet. ✨
  • --co, --creation-option <NAME>=<VALUE> β€” A lot of formats have optional dataset creation options so you can control the little particulars of the file being made. Like, the GeoPackage driver has creation options to control the version. Cute, right? πŸŽ€

May be repeated. πŸ”

Which creation options exist depends entirely on the format driver, and ngl some simple formats have literally zero creation options. You can list what a format supports with the --formats command line option, but the format's own documentation is the definitive source of truth on driver creation options. So go read the Vector drivers format specific documentation for the legal creation options of each format, bestie.

Heads up 🫢: dataset creation options are not the same thing as layer creation options. Do not confuse them, I am begging.
  • --if, --input-format <format> β€” The format/driver name you want it to attempt to open the input file(s) with. Usually you don't need this at all, but it's here for when automatic driver detection fails to pick the right one and you need to skip it entirely. You can repeat this option several times to give a whole roster of candidate drivers. πŸ’–
Important tea β˜•: it does not force those drivers to open the dataset. And some drivers have requirements on file extensions, so like, don't get mad at it.

May be repeated. πŸ”

  • --lco, --layer-creation-option <NAME>=<VALUE> β€” Same energy as --co but for layer creation options β€” the optional knobs that control particulars of the layer being created. For instance, the GeoPackage driver has layer creation options to control the feature identifier or geometry column name, setting the identifier or description, etc. 🌸

May be repeated. πŸ”

Again: what's available varies by format driver, and some simple formats have no layer creation options at all. You can list options supported for a format with the --formats command line option, but the format documentation is the definitive source of information on driver creation options. Check the Vector drivers format specific documentation for the legal creation options for each format.

Yes I'm saying it twice 😭: layer creation options are different from dataset creation options.
  • --no-create-empty-layers β€” Added in version 3.13. Skips creating layers that no features are going to be written to. If a layer would be empty, why even bother, right? Zero features, zero layer. Iconic. πŸ‘‘
  • --oo, --open-option <NAME>=<VALUE> β€” A dataset open option (format specific).

May be repeated. πŸ”

  • -f, --of, --format, --output-format <OUTPUT-FORMAT> β€” Which output vector format are we using, bestie? The allowed values may be given by:
gdal --formats | grep vector | grep rw | sort
  • --output-open-option, --output-oo <NAME>=<VALUE> β€” Added in version 3.12. A dataset open option for the output dataset (format specific). Yes, output gets its own open options now. Slay. ✨

May be repeated. πŸ”

  • --overwrite β€” Lets the program overwrite an existing target file or dataset. Otherwise, by default, <rainbow>gdal</rainbow> errors out if the target file or dataset already exists. So like, it's giving "ask permission first" energy unless you pass this. πŸ’€
  • --overwrite-layer β€” Whether overwriting the existing output vector layer is allowed. Just the layer, not the whole dataset. πŸŽ€
  • --skip-errors β€” Added in version 3.12. Should failures to write feature(s) just be ignored? πŸ™ˆ
Fr fr, be careful with this one πŸ’€: this option sets the size of the transaction unit to one feature at a time, which may cause severe slowdown when inserting into databases. You have been warned.
  • --update β€” Whether to open an existing output dataset in update mode. πŸ¦‹
  • --upsert β€” Added in version 3.12. A variant of --append where the OGRLayer::UpsertFeature() operation is used to insert or update features instead of appending with OGRLayer::CreateFeature(). Upgrade or insert, pick a lane... actually it does both. πŸ’…

This is currently implemented only in a few drivers: GPKG β€” GeoPackage vector, Elasticsearch: Geographically Encoded Objects for Elasticsearch, and MongoDBv3 (drivers that implement upsert expose the GDAL_DCAP_UPSERT capability).

The upsert operation uses the FID of the input feature, when it is set (and the FID column name is not the empty string), as the key to update existing features. It is crucial to make sure that the FID in the source and target layers are consistent. Seriously. No cap. ⚠️

For the GPKG driver, it's also possible to upsert features whose FID is unset or non-significant (the --unset-fid option of gdal vector edit can be used to ignore the FID from the source feature), when there is a UNIQUE column that is not the integer primary key.


🌈 RETURN STATUS CODE 🌈

The program returns status code 0 in case of success, and non-zero in case of error. And here's the lil plot twist: non-blocking errors emitted as warnings are considered a successful execution. So if it only warned at you, that's still a win, bestie. 🫢


πŸŽ€ EXAMPLES πŸŽ€

Example 1: Print invalidity locations to console

$ gdal vector check-geometry ne_10m_admin_0_countries.shp \
         --quiet \
         -f CSV \
         --lco GEOMETRY=AS_XY \
         --lco SEPARATOR=TAB \
         /vsistdout/
# X      Y       error
# 35.6210871060001       23.1392929140001        Ring Self-intersection

Look at that. Tab-separated X, Y and the actual error columns, straight to /vsistdout/. Find the problem, fix the problem. Main character energy. πŸ‘‘βœ¨


πŸ’œ AUTHOR πŸ’œ

Dan Baston <dbaston@gmail.com>

1998-2026


And that's the whole page, bestie πŸ’– β€” source is the <rainbow>GDAL</rainbow> manual, version-tagged, with the doc date sitting at Aug 18, 2026 (yes, it's giving time traveler, don't worry about it), and the whole thing lives under GDAL-VECTOR-CHECK-GEOMETRY(1). Go forth and check those geometries. Periodt. πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from