GDAL-VECTOR-LAYER-ALGEBRA(1)

NAME
gdal-vector-layer-algebra - Perform algebraic operation between 2 layers

Added in version 3.12.

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]
      -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)
    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 is allowed
      --update                                             Whether to open existing dataset in update mode
      --overwrite-layer                                    Whether overwriting existing output 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

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.

  Standard options

--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.

•   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.

•   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.

•   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.

•   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.

•   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.

•   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.

-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

--co <NAME>=<VALUE>
    Many formats have one or more optional dataset creation options that can be used to control particulars about the file 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.

--layer-creation-option <NAME>=<VALUE>
    Many formats have one or more optional layer creation options that can be used to 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.

--overwrite
    Allow program to overwrite existing target file or dataset. Otherwise, by default, gdal errors out if the target file or dataset already exists.

--update
    Whether the output dataset must be opened in update mode. Implies that it already exists. This mode is useful when adding new layer(s) to an already existing dataset.

--overwrite-layer
    Whether overwriting existing output layer is allowed.

--append
    Whether appending features to existing output layer is allowed

--input-layer <INPUT-LAYER>
    Name of the input vector layer.

--method-layer <METHOD-LAYER>
    Name of the method vector layer.

--output-layer <OUTPUT-LAYER>
    Name of the output vector layer.

--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. Z, M or ZM suffixes can be appended to the above values to indicate the dimensionality.

  Advanced options

--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.

--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. Defaults to method_ 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.

--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.

EXAMPLES

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

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

AUTHOR
Even Rouault <even.rouault@spatialys.com>

COPYRIGHT
1998-2025