GDAL-VECTOR-COMBINE(1)
π gdal-vector-combine(1) π
okay so bestie, welcome to gdal-vector-combine(1) β a page out of the GDAL manual (section 1, she's iconic). This is the tool that takes all ur geometries and clumps them together into collections. Very "let's all hold hands" energy. π«Ά
β¨ NAME β¨
gdal-vector-combine β Combine geometries into geometry collections.
Added in version 3.13. (she's new here and already slaying π)
πΈ SYNOPSIS πΈ
Usage: gdal vector combine [OPTIONS] <INPUT> <OUTPUT>
Combine features into collections
π₯ Positional arguments
-i,--input<INPUT>β the input vector datasets. Required, bestie, you can't skip it. π¨ Also heads up: not available in pipelines.-o,--output<OUTPUT>β where the output vector dataset goes. Required too! Also not available in pipelines.
π Common Options
-h,--helpβ shows u the help message and dips out. π--json-usageβ prints the usage as a JSON document and exits. For the data girlies. β¨--config<KEY>=<VALUE>β a configuration option. May be repeated if u got lots of them.-q,--quietβ quiet mode, meaning no progress bar and no warning messages. Peace and quiet, we love her. π Not available in pipelines.
π₯ Options
-l,--layer,--input-layer<INPUT-LAYER>β name(s) of the input layer. May be repeated. Not available in pipelines.-f,--of,--format,--output-format<OUTPUT-FORMAT>β the output format. Fun fact:"GDALG"is allowed here. π Not available in pipelines.--co,--creation-option<KEY>=<VALUE>β a creation option. May be repeated. Not available in pipelines.--lco,--layer-creation-option<KEY>=<VALUE>β a layer creation option. May be repeated. Not available in pipelines.--overwriteβ whether overwriting an existing output dataset is allowed. Not available in pipelines.--updateβ whether to open the existing dataset in update mode. Not available in pipelines.--overwrite-layerβ whether overwriting an existing output layer is allowed. Not available in pipelines.--appendβ whether appending to an existing layer is allowed. Not available in pipelines. π« Mutually exclusive with--upsertβ pick a lane, babe.--output-layer<OUTPUT-LAYER>β the output layer name. Not available in pipelines.--skip-errorsβ skip errors when writing features. Not available in pipelines.--group-by<GROUP-BY>β names of field(s) by which the inputs should be grouped. May be repeated.--keep-nestedβ avoids combining the components of multipart geometries. (Yes this is the opposite of what u might expect β the DESCRIPTION explains it, keep reading π)--add-extra-fields<ADD-EXTRA-FIELDS>β whether to add extra fields, depending on if they have identical values within each group. Value goesADD-EXTRA-FIELDS=no|sometimes-identical|always-identical(default: no).
π§ 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, which implies'append'. Not available in pipelines. π« Mutually exclusive with--append.
π DESCRIPTION π
gdal vector combine combines geometries into geometry collections. That's the whole vibe. β¨
The --group-by argument is how u decide which features get combined together. No --group-by, no grouping decisions, everything's one big happy family.
By default, the parts of multipart geometries get combined into an un-nested collection of the most specific type possible β like MultiPolygon rather than GeometryCollection. Example time: a Polygon and a two-part MultiPolygon would be combined into a three-part MultiPolygon. π
Why tho? Because many GIS file formats and software packages do not handle nested GeometryCollection types. It's giving "we can't sit with u if ur nested". π
But if u do want that nested representation, the ST_Collect-style PostGIS vibe β a two-component GeometryCollection containing the Polygon and the MultiPolygon β then hit --keep-nested and she'll do it ur way.
Also: combine can be used as a step of gdal vector pipeline. π° So u can chain her up with her friends.
π PROGRAM-SPECIFIC OPTIONS π
--group-by <FIELD_NAMES>
The names of fields whose unique values will be used to collect the input geometries. Okay so listen: any fields not listed in --group-by will be removed from the source layer. Gone. Bye. π«‘
And if --group-by is omitted entirely, the entire layer will be combined into a single feature. One feature. Just the one. π
--keep-nested
If the input geometries have multiple parts, this combines them into a GeometryCollection of the input geometries. (Nested. U asked for it. πͺ)
--add-extra-fields no|sometimes-identical|always-identical
Whether fields from source features that have the same value among the features belonging to a same group get copied to the corresponding output feature.
By default β no β only the fields listed in --group-by are copied to the output layer.
When u specify sometimes-identical: fields for which all input features within at least one output group have the same value will be copied to the output layer schema. The value of the field is the value that's common for all input features of a group. And if the input features within some group are not identical, the field value in the output for that group gets set to null. π
When u specify always-identical: fields for which all input features within a given output group have the same value are copied to the output layer, provided this condition holds for all output groups. All of them. Every single one. No exceptions. Periodt.
π INPUT FEATURES
For example, let's suppose we have four input features with the following content, and we group them by country:
name:Mainland FranceΒ·country:FranceΒ·country_fr:FranceΒ·type:continentalname:CorsicaΒ·country:FranceΒ·country_fr:FranceΒ·type:islandname:Mainland USAΒ·country:USAΒ·country_fr:Etats-Unis d'AmΓ©riqueΒ·type:continentalname:AlaskaΒ·country:USAΒ·country_fr:Etats-Unis d'AmΓ©riqueΒ·type:continental
π OUTPUT WITH SOMETIMES-IDENTICAL
With sometimes-identical, the output will be:
country:FranceΒ·country_fr:FranceΒ·type: (blank)country:USAΒ·country_fr:Etats-Unis d'AmΓ©riqueΒ·type:continental
The name field has been removed because it is distinct for each input feature (everyone's special, but that means nobody gets to stay π). The type field appears as an output field, because at least for the USA, the two grouped input features that make it have the same value. For France, its content is set to null, because its value is different in the two input features.
β OUTPUT WITH ALWAYS-IDENTICAL
With always-identical, the output will be:
country:FranceΒ·country_fr:Francecountry:USAΒ·country_fr:Etats-Unis d'AmΓ©rique
The type field has been removed because its value is different in the two input features of France. Sorry type, u almost made it. π
π― RETURN STATUS CODE π―
The program returns status code 0 in case of success, and non-zero in case of error.
Tiny little plot twist: non-blocking errors that get emitted as warnings are considered a successful execution. So a lil warning here and there is not a fail, bestie. π
π STANDARD OPTIONS π
Okay bestie, this is the part where we go flag by flag. Buckle up, it's giving β¨ thorough β¨.
--appendβ is it allowed to append features onto layer(s) that already exist? This flag says yes. Bonus: it also creates the output dataset if it's not there yet. Two birds, one slay. π¦--co,--creation-option<NAME>=<VALUE>β for setting dataset creation options. So many formats have optional dataset creation options that let you control little particulars about the file being made β like, the GeoPackage driver supports creation options to control the version, periodt.
May be repeated. π
Which dataset creation options exist totally depends on the format driver, and some simple formats have literally zero creation options. You can list what's supported for a format with the --formats command line option, but the docs for the format are the definitive source of truth on driver creation options. Go look at the Vector drivers format specific documentation for the legal creation options per format.
Heads up: dataset creation options are not the same thing as layer creation options. Do not confuse them, I'm begging. π
--if,--input-format<format>β the format/driver name you want it to try when opening the input file(s). Usually you don't need this, but it's handy for skipping automatic driver detection when that detection fails to pick the right driver. You can repeat this option several times to list several candidate drivers. But ngl β it does not force those drivers to open the dataset. Some drivers are picky about file extensions, and that's that. π
May be repeated.
--lco,--layer-creation-option<NAME>=<VALUE>β for setting layer creation options. Lots of formats have optional layer creation options to control particulars about the layer being created. Like, 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. π
Which layer creation options exist varies by format driver, and some simple formats have no layer creation options at all. You can list a format's supported options with the --formats command line option, but the format's docs are the definitive source of information on driver creation options. See the Vector drivers format specific documentation for legal creation options for each format.
And again, because it matters: layer creation options are different from dataset creation options. π«Ά
--oo,--open-option<NAME>=<VALUE>β a dataset open option (format specific).
May be repeated.
-f,--of,--format,--output-format<OUTPUT-FORMAT>β which output vector format are we using, bestie? Allowed values may be given by
gdal --formats | grep vector | grep rw | sort
--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β lets the program overwrite an existing target file or dataset. Otherwise, by default,gdaljust errors out if the target file or dataset already exists. No take-backs, no accidents. π--overwrite-layerβ whether overwriting the existing output vector layer is allowed.--skip-errorsβ added in version 3.12. β¨
Should failures to write feature(s) just be ignored? Sure, if you say so. But β οΈ this option sets the size of the transaction unit to one feature at a time, which may cause severe slowdown when inserting into databases. Lowkey a tradeoff, highkey worth knowing.
--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. iykyk.)
The upsert operation uses the FID of the input feature β when it is set, and when the FID column name is not the empty string β as the key to update existing features. It is crucial to make sure the FID in the source and target layers are consistent. Like, actually crucial. π
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. That works when there's a UNIQUE column that is not the integer primary key. πΈ
π AUTHOR π
Dan Baston <dbaston@gmail.com>
π COPYRIGHT π
1998-2026
And that's the whole page, bestie!! π This was GDAL-VECTOR-COMBINE(1) from GDAL, dated Aug 18, 2026 β go forth and combine those vectors, you absolute icon. π
β¨π
π¦ 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