GDAL-VECTOR-LAYER-ALGEBRA(1)

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

πŸ’… gdal-vector-layer-algebra πŸ’…

okay bestie, welcome to the gdal-vector-layer-algebra page from the GDAL manual (section 1) πŸŽ€ yes she's long, yes she's worth it, and no we are not skipping a single flag. buckle up. ✨


🌸 NAME 🌸

gdal-vector-layer-algebra β€” perform algebraic operation between 2 layers πŸ’ž

Added in version 3.12. so she's fresh out the box, periodt. πŸ‘‘

πŸ¦‹ SYNOPSIS πŸ¦‹

Usage: gdal vector layer-algebra [OPTIONS] <OPERATION> <INPUT> <METHOD> <OUTPUT>

Perform algebraic operation between 2 layers.

πŸŽ€ Positional arguments

  • --operation <OPERATION> β€” Operation to perform. OPERATION=union|intersection|sym-difference|identity|update|clip|erase [required] β€” like, you have to pick one, she's not optional girl. πŸ”₯
  • -i, --input <INPUT> β€” Input vector dataset [required]
  • --method <METHOD> β€” Method vector dataset [required]
  • -o, --output <OUTPUT> β€” Output vector dataset [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] β€” so like, she goes silent but only when she's not in a pipeline, iykyk. 🀫

⭐ Options

  • -f, --of, --format, --output-format <OUTPUT-FORMAT> β€” Output format
  • --co, --creation-option <KEY>=<VALUE> β€” Creation option [may be repeated] πŸ”
  • --lco, --layer-creation-option <KEY>=<VALUE> β€” Layer creation option [may be repeated] πŸ”
  • --overwrite β€” Whether overwriting existing output dataset is allowed
  • --update β€” Whether to open existing dataset in update mode
  • --overwrite-layer β€” Whether overwriting existing output layer is allowed
  • --append β€” Whether appending to existing layer is allowed
  • --input-layer <INPUT-LAYER> β€” Input layer name
  • --method-layer <METHOD-LAYER> β€” Method layer name
  • --output-layer <OUTPUT-LAYER> β€” Output layer name
  • --geometry-type <GEOMETRY-TYPE> β€” Geometry type

πŸ’œ Advanced Options

  • --oo, --open-option <KEY>=<VALUE> β€” Open options [may be repeated] πŸ”
  • --if, --input-format <INPUT-FORMAT> β€” Input formats [may be repeated] πŸ”
  • --input-prefix <INPUT-PREFIX> β€” Prefix for fields corresponding to input layer
  • --input-field <INPUT-FIELD> β€” Input field(s) to add to output layer [may be repeated] β€” Mutually exclusive with --no-input-field, --all-input-field 🚫
  • --no-input-field β€” Do not add any input field to output layer β€” Mutually exclusive with --input-field, --all-input-field 🚫
  • --all-input-field β€” Add all input fields to output layer β€” Mutually exclusive with --input-field, --no-input-field 🚫
  • --method-prefix <METHOD-PREFIX> β€” Prefix for fields corresponding to method layer
  • --method-field <METHOD-FIELD> β€” Method field(s) to add to output layer [may be repeated] β€” Mutually exclusive with --no-method-field, --all-method-field 🚫
  • --no-method-field β€” Do not add any method field to output layer β€” Mutually exclusive with --method-field, --all-method-field 🚫
  • --all-method-field β€” Add all method fields to output layer β€” Mutually exclusive with --method-field, --no-method-field 🚫

✨ DESCRIPTION ✨

so gdal vector layer-algebra performs various vector layer algebraic operations πŸ’« the command takes a vector input source and a method source and generates the output of the operation in the specified output file. that's the whole vibe: two layers walk in, one algebraic result walks out. 🫢


πŸ‘‘ PROGRAM-SPECIFIC OPTIONS πŸ‘‘

  • --geometry-type <GEOMETRY-TYPE> β€” Change the geometry type to be one of GEOMETRY, POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, GEOMETRYCOLLECTION, CURVE, CIRCULARSTRING, COMPOUNDCURVE, SURFACE, CURVEPOLYGON, MULTICURVE, MULTISURFACE, POLYHEDRALSURFACE or TIN. and listen, you can slap a Z, M or ZM suffix onto any of those values to indicate the dimensionality. adding letters like accessories, iconic. πŸ’…
  • --input-layer <INPUT-LAYER> β€” Name of the input vector layer. πŸ“›
  • --operation union|intersection|sym-difference|identity|update|clip|erase β€” Select the operation to perform among:
    • union β€” A union is a set of features, which represent areas that are in either of the operand layers. The operation is symmetric, and input and method layers can be interchanged. [image] πŸ”„
    • intersection β€” An intersection is a set of features, which represent the common areas of two layers. The operation is symmetric, and input and method layers can be interchanged. [image] 🀝
    • sym-difference β€” A symmetric difference is a set of features, which represent areas that are in operand layers but which do not intersect. The operation is symmetric, and input and method layers can be interchanged. [image] πŸ”€
    • identity β€” The identity method identifies features in the input layer with features in the method layer possibly splitting features into several features. By default the result layer has attributes from both operand layers. [image] πŸͺͺ
    • update β€” The update method creates a layer, which add features into the input layer from the method layer possibly cutting features in the input layer. By default the result layer has attributes only from the input layer. [image] πŸ†™
    • clip β€” The clip method creates a layer, which has features from the input layer clipped to the areas of the features in the method layer. By default the result layer has attributes of the input layer. [image] βœ‚οΈ
    • erase β€” The erase method creates a layer, which has features from the input layer whose areas are erased by the features in the method layer. By default the result layer has attributes of the input layer. [image] 🧽
  • --method-layer <METHOD-LAYER> β€” Name of the method vector layer. πŸ“›

🧚 Advanced options

  • --all-input-field β€” Add all input fields to output layer. Mutually exclusive with --input-field, --no-input-field. 🚫
  • --all-method-field β€” Add all method fields to output layer. Mutually exclusive with --method-field, --no-method-field. 🚫
  • --input-field <INPUT-FIELD> β€” Input field(s) to add to output layer [may be repeated] Mutually exclusive with --no-input-field, --all-input-field. πŸ”πŸš«
  • --input-prefix <INPUT-PREFIX> β€” Prefix for fields corresponding to input layer. Defaults to input_ if there are both input and method fields, otherwise empty string. 🌸
  • --method-field <METHOD-FIELD> β€” Input field(s) to add to output layer [may be repeated] Mutually exclusive with --no-method-field, --all-method-field. πŸ”πŸš«
  • --method-prefix <METHOD-PREFIX> β€” Prefix for fields corresponding to method layer. Defaults to method_ if there are both input and method fields, otherwise empty string. 🌸
  • --no-input-field β€” Do not add any input field to output layer. Mutually exclusive with --input-field, --all-input-field. 🚫
  • --no-method-field β€” Do not add any method field to output layer. Mutually exclusive with --method-field, --all-method-field. 🚫

bestie we are not done yet, there's a part 2 coming and she has more to say. don't go anywhere πŸ’–πŸ¦‹

✨ STANDARD OPTIONS ✨

okay bestie, these are the options that basically every gdal vector subcommand shares, so once you learn them here you're set for life πŸ’…

  • --append β€” whether we're allowed to append features onto layer(s) that already exist. also, lowkey iconic: this creates the output dataset if it isn't there yet. ✨
  • --co, --creation-option <NAME>=<VALUE> β€” tons of formats have one or more optional dataset creation options, and these let you control little particulars about the file being created. like, for example, the GeoPackage driver supports creation options that control the version. πŸŽ€

May be repeated.

The dataset creation options you get vary by format driver, and some of the simple formats have literally no creation options at all (rip 🫢). you can list the options a format supports with the --formats command line option, but the documentation for the format is the definitive source of info on driver creation options. check the Vector drivers format specific documentation for the legal creation options of each format.

heads up bestie: dataset creation options are different from layer creation options. don't get it twisted πŸ’€
  • --if, --input-format <format> β€” the format/driver name we should try to open the input file(s) with. generally you don't need to specify this, but it's there to skip automatic driver detection when the autodetect fails to pick the right driver. can be repeated several times to give several candidate drivers. note that it does not force those drivers to open the dataset β€” and in particular, some drivers have requirements on file extensions. πŸ™ˆ

May be repeated.

  • --lco, --layer-creation-option <NAME>=<VALUE> β€” lots of formats have optional layer creation options that 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. so many vibes ✨

May be repeated.

Which layer creation options exist varies by format driver, and some simple formats have none at all. you can list the options a format supports with the --formats command line option, but again, the documentation for the format is the definitive source of info on driver creation options. See Vector drivers format specific documentation for legal creation options for each format.

and yes, layer creation options are different from dataset creation options. two separate girlies, two separate jobs 😭
  • --oo, --open-option <NAME>=<VALUE> β€” dataset open option (format specific). that's it, that's the whole thing πŸ’œ

May be repeated.

  • -f, --of, --format, --output-format <OUTPUT-FORMAT> β€” which output vector format we're using. the allowed values can be given by:
gdal --formats | grep vector | grep rw | sort

run that and let it tell you the tea β˜•

  • --output-layer <NAME> β€” specifies the name of the layer the features get written to. if you don't specify it, output layer names will just be the same as the input layer names. main character names carrying over, love that for us πŸ‘‘
  • --overwrite β€” lets the program overwrite an existing target file or dataset. otherwise, by default, gdal errors out if the target file or dataset already exists. so if you want it gone, say so fr fr 🌸
  • --overwrite-layer β€” whether overwriting the existing output vector layer is allowed. ✨
  • --update β€” whether to open an existing output dataset in update mode. πŸ¦‹

πŸ’« RETURN STATUS CODE πŸ’«

the program returns status code 0 when it slays (success), and non-zero when it doesn't (error). and no cap: non-blocking errors that get emitted as warnings are still counted as a successful execution, so don't panic πŸ’…


πŸŽ€ EXAMPLES πŸŽ€

Example 1: Performs a union between both input and method layers.

$ gdal vector layer-algebra union input.shp method.shp output.shp

literally copy, paste, watch it cook πŸ”₯


🌈 AUTHOR 🌈

Even Rouault <even.rouault@spatialys.com>

(a legend, honestly πŸ‘‘)


1998-2026


okay bestie, that's the whole page!! this was GDAL-VECTOR-LAYER-ALGEBRA(1), dated Aug 18, 2026 β€” screenshot it, bookmark it, tattoo it, whatever, just go do your layer algebra and slay πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from