GDAL-VECTOR-SEGMENTIZE(1)

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

πŸ’– GDAL-VECTOR-SEGMENTIZE(1) πŸ’–

okay bestie, welcome to the GDAL manual β€” this one's for gdal-vector-segmentize(1), a whole icon in the GDAL lineup. She segments geometries of a vector dataset, she's brand new (added in version 3.12) and honestly? she ate. ✨


🌸 NAME 🌸

gdal-vector-segmentize β€” segmentize geometries of a vector dataset πŸ¦‹

Added in version 3.12. (yeah, she's a baby, a very talented baby)


πŸŽ€ SYNOPSIS πŸŽ€

Usage: gdal vector segmentize [OPTIONS] <INPUT> <OUTPUT> <MAX-LENGTH>

Segmentize 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]
  --max-length <MAX-LENGTH>                            Maximum length of a segment [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:
  -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

like, look at her. three required things: <INPUT>, <OUTPUT>, <MAX-LENGTH>. no notes. πŸ’…


✨ DESCRIPTION ✨

gdal vector segmentize makes sure that segments of LineStrings or rings of Polygons are not longer than the max length you gave her, by inserting intermediate points. basically she sprinkles extra points onto your lines so nothing is overstretched. it's giving pilates for geometries. πŸ§˜β€β™€οΈ

she runs the OGRGeometry::segmentize() operation. that's the whole engine. no cap.

and yes, she can also be used as a step of gdal vector pipeline. 🫢


πŸ¦‹ GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) πŸ¦‹

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 apply the specified pipeline in a on-the-fly / streamed way. so you save the recipe instead of the cake. iconic behaviour honestly πŸ”₯


πŸ’œ PROGRAM-SPECIFIC OPTIONS πŸ’œ

  • --max-length <MAX-LENGTH> β€” the value you give here is the maximum distance between two consecutive points of the output geometry before intermediate points get added. and the unit of the distance? georeferenced units of the source layer. so don't come at her with meters if your layer is in degrees, she will simply do what you said 😭

🌈 STANDARD OPTIONS 🌈

  • --active-geometry <ACTIVE-GEOMETRY> β€” sets the active geometry field, by its name. when you specify it, only that geometry field gets processed, and all the other geometry fields stay untouched (they're just vibing). if you don't specify it, all geometry fields get processed. you can combine this with --active-layer, they're besties 🀝
  • --active-layer <ACTIVE-LAYER> β€” sets the active layer. when it's specified, only the layer you named gets processed. other layers? not modified, not bothered. if you don't specify it, all layers get processed. generous queen.
  • --append β€” whether appending features to existing layer(s) is allowed. this also creates the output dataset if it doesn't exist yet. so she'll build it AND fill it, a multitasker πŸ’…
  • --co, --creation-option <NAME>=<VALUE> β€” many formats have one or more optional dataset creation options that control particulars about the file being 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.

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). generally you don't need to specify it, but it's handy to skip automatic driver detection when that fails to pick the right 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 β€” and some drivers have requirements on file extensions, so no promises okay 😌

may be repeated.

  • --input-layer <INPUT-LAYER> β€” specifies the name of one or more layers to process. by default, all layers get processed. if you want to read and write all layers but only process a subset, use --active-layer. subtle but important, bestie.
  • --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.

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. the way I keep saying this 😭
  • --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 by gdal --formats | grep vector | grep rw | sort ✨
  • --output-layer <NAME> β€” specifies the name of the layer to which features will be written. if you don't specify it, the output layer names will be the same as the input layer names. she's a copycat and we love that for her πŸ’–
  • --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, gdal errors out if the target file or dataset already exists. so if you don't pass this and the file's there? she's gonna yell. 😀
  • --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. 🚨 but real talk: this option sets the size of the transaction unit to one feature at a time, which may cause severe slowdown when inserting into databases. like, tragic levels of slow.

  • --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. ⚠️ do not skip this step, bestie.

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 a warning is not a flop, it's just a lil note πŸ“


πŸ“ EXAMPLES πŸ“

Example 1: Make sure that segments of geometries are no longer than one km

(assuming the CRS is in meters, okay? units matter, she's not a mind reader πŸ’€)

$ gdal vector segmentize --max-length=1000 in.gpkg out.gpkg --overwrite

πŸ’œ AUTHOR πŸ’œ

Even Rouault <even.rouault@spatialys.com> β€” icon, legend, the moment πŸ‘‘


1998-2026


and that's the whole page bestie!! tysm for reading, gdal-vector-segmentize says slay, and this was the GDAL manual, dated Aug 18, 2026 πŸ’–βœ¨πŸ¦‹ go make some little segments now, fr fr πŸ’…πŸŽ€

πŸ“¦ where this page comes from