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--excludeis 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--fieldsdoes 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-layerinstead. That's the distinction, iykyk.--lco,--layer-creation-option <NAME>=<VALUE>β same energy as--cobut 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 defaultgdalerrors 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--appendwhereOGRLayer::UpsertFeature()is used to insert or update features instead of appending withOGRLayer::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
0in 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 π
πΈ COPYRIGHT πΈ
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
- alpine 3.24: gdal-doc 3.13.3-r0 Β· MIT
- arch rolling: gdal 3.13.3-6 Β· MIT
- ubuntu stonking: gdal-bin 3.13.3+dfsg-1ubuntu4 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms