GDAL-VECTOR-SELECT(1)

πŸŽ€ NAME πŸŽ€

okay bestie, welcome to the GDAL-VECTOR-SELECT(1) manual page β€” this is the GDAL one, section one, and it's all about gdal-vector-select: the tool that selects a subset of fields from a vector dataset. πŸ’…

She was Added in version 3.11 ✨ so yes, she's new, she's fresh, she's serving.


🌸 SYNOPSIS 🌸

Usage: gdal vector select [OPTIONS] <INPUT> <OUTPUT> <FIELDS>

Select a subset of fields from a vector dataset.

Positional arguments:
  -i, --input <INPUT>                                  Input vector datasets [required] [not available in pipelines]
  -o, --output <OUTPUT>                                Output vector dataset [required] [not available in pipelines]
  --fields <FIELDS>                                    Fields to select (or exclude if --exclude) [may be repeated] [required]

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
  --skip-errors                                        Skip errors when writing features [not available in pipelines]
  --active-layer <ACTIVE-LAYER>                        Set active layer (if not specified, all)
  --exclude                                            Exclude specified fields
                                                       Mutually exclusive with --ignore-missing-fields
  --ignore-missing-fields                              Ignore missing fields
                                                       Mutually exclusive with --exclude

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

and yes, that whole menu is the vibe check ✨ every single flag, every single "not available in pipelines", every mutual-exclusion drama is up there, no cap.


πŸ¦‹ DESCRIPTION πŸ¦‹

gdal vector select can be used to select a subset of fields. that's the whole serve. πŸ’–

and plot twist bestie β€” select can also be used as a step of gdal vector pipeline. so it's not just a standalone icon, she's also a team player 🫢


πŸ’« GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) πŸ’«

This program supports serializing the command line as a JSON file using the GDALG output format. 😭 iconic behaviour honestly.

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. ✨ so it just… runs. live. streaming. main character energy fr fr.


πŸ‘‘ PROGRAM-SPECIFIC OPTIONS πŸ‘‘

  • --exclude β€” flips the whole algorithm's behaviour: now all fields are selected, except the ones mentioned by --fields πŸ™ˆ so instead of a cute little guest list of who gets in, it's a block list of who doesn't. pick your fighter.
  • --fields <FIELDS> β€” a comma-separated list of fields from the input layer to copy to the new layer… or to exclude if --exclude is specified. she contains multitudes πŸ’…

Field names with spaces, commas or double-quote should be surrounded with a starting and ending double-quote character, and double-quote characters in a field name should be escaped with backslash. yes, it's giving nesting-doll quoting, i know, i know 😭

Depending on the shell used, this might require further quoting. for example, to select regular_field, a_field_with space, and comma and a field with " double quote with a Unix shell:

--fields "regular_field,\"a_field_with space, and comma\",\"a field with \\\" double quote\""

A field is only selected once, even if mentioned several times in the list. (she does not do duplicates, she's not that kind of tool πŸŽ€)

Geometry fields can also be specified in the list. If the source layer has no explicit name for the geometry field, _ogr_geometry_ must be used to select the unique geometry field. ⭐

Specifying a non-existing source field name results in an error. it's not a suggestion, bestie, it's a hard no πŸ’€
  • --ignore-missing-fields β€” By default, if a field specified by --fields does not exist in the input layer(s), an error is emitted and the processing is stopped. πŸ›‘

When specifying --ignore-missing-fields, only a warning is emitted and the non existing fields are just ignored. 🌈 so the show goes on, she simply chooses peace.


and that's only the first half of the lore β€” this page is not done with you yet 🧚

✨ STANDARD OPTIONS ✨

Okay bestie, these are the options that basically every gdal vector tool shares, so once you learn them here you're set for life πŸ’…

  • --active-layer <ACTIVE-LAYER> β€” pick your one true layer. When you set this, only the layer with that exact name gets processed β€” every other layer just sits there untouched, minding its own business. Skip this option entirely and it's all layers on deck, all of them getting processed. No cap.
  • --append β€” are we allowed to append features onto layer(s) that already exist? This is the yes. And bonus: it also creates the output dataset if it doesn't exist yet, so it's giving "make it if it's not there, add to it if it is." 🫢
  • --co, --creation-option <NAME>=<VALUE> β€” so many formats have optional dataset creation options that let you control little particulars about the file being created. Like, the GeoPackage driver supports creation options that control the version. Cute!

May be repeated. πŸ”

Which creation options exist depends fully on the format driver, and some simple formats have, like, zero creation options. Sad for them. You can list the options a format supports with the --formats command line option, but honestly the format's own documentation is the definitive source on driver creation options β€” go read it. See the Vector drivers format specific documentation for the legal creation options for each format.

Heads up: dataset creation options are NOT the same thing as layer creation options. Different creatures, don't mix them up πŸ™ˆ
  • --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 lowkey a lifesaver when automatic driver detection fails to pick the right driver and you need to skip that whole guessing game. You can repeat this option several times to hand it several candidate drivers.

May be repeated. πŸ”

Careful though β€” it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions, so they can still ghost you. 😭
  • --input-layer <INPUT-LAYER> β€” name one or more layers you want to process. By default every layer gets processed. And here's the pro move: if you want to read and write all the layers but only process a subset, use --active-layer instead. That's the distinction, iykyk.
  • --lco, --layer-creation-option <NAME>=<VALUE> β€” same energy as --co but for layer creation options, which control particulars about 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. Obsessed.

May be repeated. πŸ”

Which layer creation options exist varies by format driver, and again some simple formats have none at all. List what a format supports with --formats, but the format documentation is the definitive source for driver creation options. See the Vector drivers format specific documentation for the legal creation options for each format.

And yes, layer creation options are different from dataset creation options. (Said it twice because it matters.) πŸ’€
  • --oo, --open-option <NAME>=<VALUE> β€” dataset open option, format specific. That's it, that's the whole vibe.

May be repeated. πŸ”

  • -f, --of, --format, --output-format <OUTPUT-FORMAT> β€” which output vector format do you want? Allowed values can be found with:
gdal --formats | grep vector | grep rw | sort

(Yes queen, pipe it and sort it, chef's kiss πŸ‘‘)

  • --output-layer <NAME> β€” the name of the layer where your features get written. Leave it out and the output layer names will just match the input layer names. Simple, iconic.
  • --output-open-option, --output-oo <NAME>=<VALUE> β€” dataset open option for the output dataset (format specific).
Added in version 3.12. ✨

May be repeated. πŸ”

  • --overwrite β€” lets the program overwrite an existing target file or dataset. Without it, by default gdal errors out if the target file or dataset already exists. So if you're getting yelled at, this is probably why 🫠
  • --overwrite-layer β€” whether overwriting the existing output vector layer is allowed. Layer-level drama, separate from file-level drama.
  • --skip-errors β€” whether failures to write feature(s) should just be ignored.
Added in version 3.12. ✨
Real talk: this option sets the size of the transaction unit to one feature at a time, which may cause severe slowdown when inserting into databases. Convenient, but it's giving snail energy 🐌
  • --update β€” whether to open an existing output dataset in update mode.
  • --upsert β€” a variant of --append where OGRLayer::UpsertFeature() is used to insert or update features instead of appending with OGRLayer::CreateFeature().
Added in version 3.12. ✨

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, check that. πŸ”

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. Slay, GeoPackage πŸŽ€


🌈 RETURN STATUS CODE 🌈

Real simple, bestie:

  • It returns status code 0 in case of success. πŸŽ‰
  • It returns non-zero in case of error.

And a lil plot twist for you: non-blocking errors emitted as warnings are considered a successful execution. So a warning is not a fail, it's just a warning, periodt. πŸ’–


πŸ¦‹ EXAMPLES πŸ¦‹

Example 1: Select the EAS_ID field and the geometry field from a Shapefile

$ gdal vector select in.shp out.gpkg "EAS_ID,_ogr_geometry_" --overwrite

Just the two fields, nothing extra, clean and minimal ✨

Example 2: Remove sensitive fields from a layer

$ gdal vector select in.shp out.gpkg --exclude "name,surname,address" --overwrite

Not the name, not the surname, not the address β€” we're keeping that private, thank you very much πŸ”’


πŸ’œ AUTHOR πŸ’œ

Even Rouault <even.rouault@spatialys.com> β€” thank you for your service, king πŸ‘‘

1998-2026


And that's the whole page, babes 🫢 This was GDAL-VECTOR-SELECT(1) from the GDAL crew, dated Aug 18, 2026 β€” so if you're reading this sometime after that, welcome to the future, you're doing amazing, go select some vectors and make it iconic πŸ’…βœ¨πŸŒˆ

πŸ“¦ where this page comes from