GDAL-VECTOR-RENAME-LAYER(1)
π gdal-vector-rename-layer(1) β the GDAL manual, and yes it's β¨iconicβ¨
okay so bestie, you found the manual page for gdal-vector-rename-layer from the GDAL docs, and honestly? it's lowkey a glow-up tool for your layer names. sit down, hydrate, and let's read it together π«Ά
β¨ NAME β¨
gdal-vector-rename-layer β rename layer(s) of a vector dataset π
Added in version 3.13. fr fr, it's a newer one, no cap.
πΈ SYNOPSIS πΈ
okay so the vibe is:
Usage: gdal vector rename-layer [OPTIONS] <INPUT> <OUTPUT>
Rename layer(s) 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:
-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]
-l, --input-layer <INPUT-LAYER> Input layer name
--ascii Force names to ASCII character
--lower-case Force names to lower case (only on ASCII characters)
--filename-compatible Force names to be usable as filenames
--reserved-characters <RESERVED-CHARACTERS> Reserved character(s) to be removed
--replacement-character <REPLACEMENT-CHARACTER> Replacement character when ASCII conversion not possible
--max-length <MAX-LENGTH> Maximum length of layer names
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
see how the flags with [not available in pipelines] are all marked? that's your warning that the gdal vector pipeline girlies can't use those ones. noted. π
π¦ DESCRIPTION π¦
so gdal vector rename-layer is the tool you use to rename layer(s). that's it, that's the whole job, and it does it fabulously.
It has two modes:
- one where you rename a single layer to a given name with
--output-layer, and you pair it with--input-layerif the dataset has more than one layer in it. - another one where you're allowed to force a bunch of operations that alter the layer names:
- Force characters to ASCII:
--ascii - Force characters to lower case:
--lower-case - Force compatibility with file names:
--filename-compatible - Remove or replace characters from a list of reserved characters:
--reserved-characters - Truncate to a maximum number of characters:
--max-length
- Force characters to ASCII:
For --filename-compatible and --reserved-characters, incompatible characters get removed, unless you specify --replacement-character. (then they get swapped instead, periodt π
)
In this mode, uniqueness of layer names is also attempted by appending _{N} where NN is a sequence number.
β οΈ heads up bestie: uniqueness may not be achieved if --max-length is set to a too low value. so don't be out here truncating to like 3 characters and then acting surprised.
This subcommand is also available as a potential step of gdal vector pipeline π iykyk.
π PROGRAM SPECIFIC OPTIONS π
these are the ones that make this command this command, you know?
--input-layer <INPUT-LAYER>β the name of the input layer. bestie, this one is meant to be used together with--output-layer. they're a duo, don't split them up π--output-layer <OUTPUT-LAYER>β the name of the output layer. if there are several input layers, you also have to specify--output-layer. no skipping it, fr.--asciiβ force characters to ASCII. rn only accented characters in the Latin 1 Supplement and Latin Extended A character set have a sensible ASCII replacement. every other non-ASCII character gets removed or replaced by the replacement character you specified with--replacement-character. so like, set that one if you care β¨--lower-caseβ force characters to lower-case. currently only ASCII upper case characters are replaced. and here's the tea: this option is applied after--ascii, if the latter is specified. order matters, queen π--filename-compatibleβ force layer names to be compatible with file names for Linux, Windows or MacOS, independently from the operating system on which this command is actually run. so it's safe across all the platforms, no matter where you're sitting π--reserved-characters <RESERVED-CHARACTERS>β reserved character(s) to remove, or to replace with the replacement character specified with--replacement-characterπ«--replacement-character <REPLACEMENT-CHARACTER>β the replacement character used when ASCII conversion is not possible, or to substitute for reserved characters. your lil β¨glow-upβ¨ character, if you will.--max-length <MAX-LENGTH>β truncate to a maximum number of characters βοΈ
π STANDARD OPTIONS π
the classics. the ones that show up everywhere. still gotta know them tho.
--appendβ whether appending features to existing layer(s) is allowed. this also creates the output dataset if it does not exist yet. convenient, honestly.--co,--creation-option <NAME>=<VALUE>β lots of formats have one or more optional dataset creation options you can use to control particulars about the file being created. for instance, the GeoPackage driver supports creation options to control the version. π
May be repeated. (say it as many times as you need, she's flexible π )
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 confuse your girls!!
--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 you can use it to skip automatic driver detection when that 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.
--lco,--layer-creation-option <NAME>=<VALUE>β lots of formats have one or more optional layer creation options to control particulars about the layer being 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.
π and again: layer creation options are different from dataset creation options. yes we're repeating it. yes 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
(yes, that's the actual command, bestie β pipe it, grep it, sort it, slay π )
--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. simple as that π¦--output-open-option,--output-oo <NAME>=<VALUE>β Added in version 3.12.
dataset open option for the output dataset (format specific).
May be repeated.
--overwriteβ allow the program to overwrite an existing target file or dataset. otherwise, by default,gdalerrors out if the target file or dataset already exists. so if you want the overwrite energy, say so π--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. but bestie, listen: this option sets the size of the transaction unit to one feature at a time, which may cause severe slowdown when inserting into databases. so it's giving convenience but it's also giving pain π
--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().
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. fr fr, do not mess this up.
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. π
okay and that's where this part wraps up β there's more coming, so stay tuned bestie π
β¨ RETURN STATUS CODE β¨
Okay bestie, here's the vibe check on exit codes π
0β slay! The program returns this when everything goes right, aka success. π- non-zero β not the vibe. The program returns this when there's an error. π
Lowkey important: non-blocking errors that get emitted as warnings are still counted as a successful execution. So don't panic if you see a lil warning, that's just the program being chatty.
πΈ EXAMPLES πΈ
π Example 1: Rename a given layer to a user selected name.
$ gdal vector rename-layer input.gpkg output.gpkg --input-layer "name with space" --output-layer "without_space"
The way this one is just chef's kiss β¨ β you tell it which layer you want with --input-layer (spaces and all, it's giving "name with space"), and you tell it what you want it to become with --output-layer (here: without_space, no space, iconic).
π¦ Example 2: Force layer names to ASCII, lower case, without space character and to be filename compatible.
$ gdal vector rename-layer input.gpkg output_shp_directory --output-format "ESRI Shapefile" --ascii --lower-case --filename-compatible --reserved-characters " "
Okay so this one is the full glow-up π β you're writing out to a directory and hitting it with all the flags: --output-format "ESRI Shapefile" to set the format, --ascii to force ASCII, --lower-case to force lower case, --filename-compatible to make it play nice with filenames, and --reserved-characters " " to declare the space character the reserved one it needs to deal with. Periodt. π
π AUTHOR π
Even Rouault <even.rouault@spatialys.com> β we stan. π«Ά
π COPYRIGHT π
1998-2026 β yes bestie, that's the whole copyright line, no cap.
And that's a wrap on GDAL-VECTOR-RENAME-LAYER(1) fr fr π β this cutie comes from the GDAL source, version dated Aug 18, 2026 πΈ thanks for reading the whole thing, you ate that, go rename some layers and be the main character of your own geospatial pipeline πβ¨π
π¦ 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