Scroll to navigation

GDAL-VECTOR-LAYER-ALGEBRA(1) GDAL 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 or warning message) [not available in pipelines] 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

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.

PROGRAM-SPECIFIC OPTIONS

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.

Name of the input vector layer.

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]




Name of the method vector layer.

Advanced options

Add all input fields to output layer. Mutually exclusive with --input-field, --no-input-field.

Add all method fields to output layer. Mutually exclusive with --method-field, --no-method-field.

Input field(s) to add to output layer [may be repeated] Mutually exclusive with --no-input-field, --all-input-field.

Prefix for fields corresponding to input layer. Defaults to input_ if there are both input and method fields, otherwise empty string.

Input field(s) to add to output layer [may be repeated] Mutually exclusive with --no-method-field, --all-method-field.

Prefix for fields corresponding to method layer. Defaults to method_ if there are both input and method fields, otherwise empty string.

Do not add any input field to output layer. Mutually exclusive with --input-field, --all-input-field.

Do not add any method field to output layer. Mutually exclusive with --method-field, --all-method-field.

STANDARD OPTIONS

Whether appending features to existing layer(s) is allowed. This also creates the output dataset if it does not exist yet.

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.


Format/driver name to be attempted to open the input file(s). It is 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.


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.


Dataset open option (format specific).

May be repeated.


Which output vector format to use. Allowed values may be given by gdal --formats | grep vector | grep rw | sort

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.

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.

Whether to open an existing output dataset in update mode.

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

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

May 8, 2026