GDAL-VECTOR-SET-FIELD-TYPE(1)

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

πŸ’… 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-name and --input-field-type literally 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, gdal errors 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 🫢


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