GDAL-VECTOR-SET-FIELD-TYPE(1)
π gdal-vector-set-field-type π
okay bestie, gather round π«Ά this is the gdal-vector-set-field-type page from the GDAL manual β yes, the one filed under GDAL-VECTOR-SET-FIELD-TYPE(1) (that's the header, folded in here so it doesn't get lonely at the top β¨).
πΈ NAME πΈ
gdal-vector-set-field-type β modify the type of a field of a vector dataset
Added in version 3.12.
π¦ SYNOPSIS π¦
Usage: gdal vector set-field-type [OPTIONS] <INPUT> <OUTPUT>
Modify the type of a field of 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]
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]
--active-layer <ACTIVE-LAYER> Set active layer (if not specified, all)
--field-name <FIELD-NAME> Field name [required]
Mutually exclusive with --input-field-type
--input-field-type <INPUT-FIELD-TYPE> Source field type or subtype [required]
Mutually exclusive with --field-name
--output-field-type, --field-type <FIELD-TYPE> Target field type or subtype [required]
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
that's the usage dump, verbatim, untouched, zero notes taken π
π DESCRIPTION π
gdal vector set-field-type is your girl for changing up the field type of a vector dataset:
it's giving "glow up for one specific column" β¨
and the iconique part? set-field-type can also be used as a step of gdal vector pipeline. so you can slot it right into a whole pipeline and let it cook π₯
π GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) π
this program supports serializing the command line as a JSON file using the GDALG output format π once you've got that file, you can open it as a vector dataset using the GDALG: GDAL Streamed Algorithm driver, and it'll apply the specified pipeline in a on-the-fly / streamed way. no cap, it just streams π«
β PROGRAM-SPECIFIC OPTIONS β
--field-name <FIELD-NAME>β the name of the field you wanna modify. that's it, that's the job π
Mutually exclusive with --input-field-type. One of them is required.
--field-type,--output-field-type <FIELD-TYPE>β the new field type. valid values are:Integer,IntegerList,Real,RealList,String,StringList,Binary,Date,Time,DateTime,Integer64,Integer64List. a field subtype can be specified instead of a field type. valid values are:Boolean,Int16,Float32,JSON,UUID. the field type will be derived from the subtype π¦--input-field-type <FIELD-TYPE>β the field type of the fields to modify. valid values are:Integer,IntegerList,Real,RealList,String,StringList,Binary,Date,Time,DateTime,Integer64,Integer64List. a field subtype can be specified instead of a field type. valid values are:Boolean,Int16,Float32,JSON,UUID.
Mutually exclusive with --field-name. One of them is required.
not me pointing out that--field-nameand--input-field-typeliterally cannot be in the same room together π pick one, bestie, one of them is required, that's the rules.
π STANDARD OPTIONS π
--active-layer <ACTIVE-LAYER>β set the active layer. when it's specified, only the layer specified by its name will be subject to the processing. other layers will be not modified π if this option is not specified, all layers will be subject to the processing.--appendβ whether appending features to existing layer(s) is allowed. this also creates the output dataset if it does not exist yet β¨--co,--creation-option <NAME>=<VALUE>β so many formats have one or more optional dataset creation options that control the particulars of the file being created. for instance, the GeoPackage driver supports creation options to control the version π
May be repeated.
the dataset creation options available vary by format driver, and some simple formats have no creation options at all. a list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. see Vector drivers format specific documentation for legal creation options for each format π
note that dataset creation options are different from layer creation options. do not conflate them, i'm begging π
--if,--input-format <format>β format/driver name to be attempted to open the input file(s). it's generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. this option can be repeated several times to specify several candidate drivers. note that it does not force those drivers to open the dataset. in particular, some drivers have requirements on file extensions π¦
May be repeated.
--input-layer <INPUT-LAYER>β specifies the name of one or more layers to process. by default, all layers will be processed. to read and write all layers but only process a subset, use--active-layerπ--lco,--layer-creation-option <NAME>=<VALUE>β many formats have one or more optional layer creation options that control particulars about the layer created. for instance, the GeoPackage driver supports layer creation options to control the feature identifier or geometry column name, setting the identifier or description, etc π
May be repeated.
the layer creation options available vary by format driver, and some simple formats have no layer creation options at all. a list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. see Vector drivers format specific documentation for legal creation options for each format πΈ
note that layer creation options are different from dataset creation options. (yes i'm repeating myself, it matters π€)
--oo,--open-option <NAME>=<VALUE>β dataset open option (format specific). β¨
May be repeated.
-f,--of,--format,--output-format <OUTPUT-FORMAT>β which output vector format to use. allowed values may be given by:
gdal --formats | grep vector | grep rw | sort
--output-layer <NAME>β specifies the name of the layer to which features will be written. if not specified, output layer names will be the same as input layer names π--output-open-option,--output-oo <NAME>=<VALUE>β Added in version 3.12.
Dataset open option for output dataset (format specific).
May be repeated.
--overwriteβ allow program to overwrite existing target file or dataset. otherwise, by default,gdalerrors out if the target file or dataset already exists π±--overwrite-layerβ whether overwriting the existing output vector layer is allowed.--skip-errorsβ Added in version 3.12.
whether failures to write feature(s) should be ignored. note that this option sets the size of the transaction unit to one feature at a time, which may cause severe slowdown when inserting into databases. π fr fr, be careful with this one.
--updateβ whether to open an existing output dataset in update mode.--upsertβ Added in version 3.12.
variant of --append where the OGRLayer::UpsertFeature() operation is used to insert or update features instead of appending with OGRLayer::CreateFeature().
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. π¨
for the GPKG driver, it is 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 (non-blocking errors emitted as warnings are considered as a successful execution). so 0 = slay, non-zero = not slay π
β¨ EXAMPLES β¨
okay bestie this is the part where it all clicks, fr fr π two lil examples and then you're literally a gdal vector set-field-type girlie
πΈ Example 1: Change the type of a field given by its name to Integer
so you've got a field called myfield and it's Giving String Energy and you want it to be an Integer instead? say less π
you name the field, you name the type, and you go:
$ gdal vector set-field-type input.gpkg output.gpkg --field-name myfield --field-type Integer
that's it. that's the whole thing. input.gpkg goes in, output.gpkg comes out, and myfield is now an Integer. slay π
π¦ Example 2: Change the type of all fields of type Date to DateTime
not you wanting to bulk-convert every Date field into a DateTime in one single command π₯ iconic behaviour ngl. you don't even need to know the field names β you just point at the input type and the output type and let it cook:
$ gdal vector set-field-type input.gpkg output.gpkg --input-field-type Date --output-field-type DateTime
every field that was chillin as a Date wakes up as a DateTime. no cap. main character energy from a two-flag command ππ
π AUTHOR
Alessandro Pasotti <elpaso@itopen.it> β yes the actual human, the one who wrote this, the author of the whole vibe π«Ά
π COPYRIGHT
1998-2026
and that's the whole page bestie!! π you just read GDAL-VECTOR-SET-FIELD-TYPE(1) β from the GDAL docs, dated Aug 18, 2026 β go forth, convert those field types, and be sooo normal about it πβ¨π§
π¦ 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