GDAL-VECTOR-SWAP-XY(1)
π NAME π
gdal-vector-swap-xy β swaps the X and Y coordinates of the geometries in a vector dataset, bestie. That's it, that's the whole job.
Added in version 3.12.
β¨ SYNOPSIS β¨
Usage: gdal vector swap-xy [OPTIONS] <INPUT> <OUTPUT>
Swap X and Y coordinates of geometries 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)
--active-geometry <ACTIVE-GEOMETRY> Geometry field name to which to restrict the processing (if not specified, all)
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
π¦ DESCRIPTION π¦
So gdal vector swap-xy does exactly one dramatic thing: it swaps the X and Y coordinates of geometries. Why would you want that, you ask? Mainly to work around axis order issues of coordinate reference systems. Yep, the classic "why is my map sideways" moment. We've all been there. π
It can also be used as a step of gdal vector pipeline, so you can slot it into your lil streamed pipeline moment. Slay. π
π GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) π
Okay so this is the cool part. This program supports serializing the command line as a JSON file using the GDALG output format.
The resulting file can then be opened 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 does it live. β¨
π STANDARD OPTIONS π
--active-geometry <ACTIVE-GEOMETRY>β Sets the active geometry field, by its name. When you specify it, only that one geometry field gets processed, and every other geometry field stays untouched (not modified, periodt). If you don't specify it, all geometry fields get the treatment. And yes, you can combine this with--active-layer. π«Ά--active-layer <ACTIVE-LAYER>β Sets the active layer. When you specify it, only the layer named there gets processed. Every other layer is left alone, unbothered, thriving. If you don't specify it, all layers get processed.--appendβ Whether appending features to existing layer(s) is allowed. This also creates the output dataset if it does not exist yet. Two birds, one cute lil flag. π--co, --creation-option <NAME>=<VALUE>β So many formats have one or more optional dataset creation options, and they let you control particulars about the file being created. Like, for instance, the GeoPackage driver supports creation options to control the version. Fancy.
May be repeated.
The dataset creation options available vary by format driver, and some simple formats have no creation options at all. You can list the options supported for a format 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.
Heads up bestie: dataset creation options are different from layer creation options. Don't mix them up. π
--if, --input-format <format>β Format/driver name to be attempted to open the input file(s). Usually you don't need to specify it, but you can use it to skip automatic driver detection when it fails to select the appropriate driver. You can repeat this option several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset β and some drivers have requirements on file extensions, so like, read the room. π
May be repeated.
--input-layer <INPUT-LAYER>β Specifies the name of one or more layers to process. By default, all layers will be processed. If you want 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. So many lil knobs to turn.
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. We said what we said. π«Ά
--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 bygdal --formats | grep vector | grep rw | sort. That command is literally right there, use it. π₯--output-layer <NAME>β Specifies the name of the layer to which features will be written. If you don't specify it, output layer names will be the same as input layer names. Effortless. β¨--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 the program to overwrite an existing target file or dataset. Otherwise, by default,gdalerrors out if the target file or dataset already exists. Like, it will simply refuse. Drama. π--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. So yeah, convenient but it's giving pain if you're doing bulk work. π
--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 skip that check. β οΈ
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.
π 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 don't panic if you see a lil warning in the chat. π«Ά
πΈ EXAMPLES πΈ
Example 1: Basic usage
$ gdal vector swap-xy in.gpkg out.gpkg --overwrite
Ate. No notes. π
π AUTHOR π
Even Rouault <even.rouault@spatialys.com>
π COPYRIGHT π
1998-2026
okay bestie that's the whole page, you're officially a swap-xy expert now, go flip some axes π
This lil love letter to coordinate swapping is GDAL-VECTOR-SWAP-XY(1) from the GDAL manual, dated Aug 18, 2026. Mwah. π¦β¨
π¦ 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