GDAL-VECTOR-SORT(1)

πŸ“¦ version 3.13.3, in alpine 3.24, arch rolling, ubuntu stonking

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

okay bestie, welcome to the gdal-vector-sort page from the GDAL manual 🫢 this one's all about spatially sorting a vector dataset, and yes it is iconic. also she's new β€” Added in version 3.13 ✨


✨ NAME ✨

gdal-vector-sort β€” spatially sort a vector dataset πŸ’…

Added in version 3.13.

🌸 SYNOPSIS 🌸

Usage: gdal vector sort [OPTIONS] <INPUT> <OUTPUT>

Spatially order the features in a layer

Positional arguments:
  -i, --input <INPUT>                                  Input vector datasets [required] [not available in pipelines]
  -o, --output <OUTPUT>                                Output vector dataset [required] [not available in pipelines]

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]
  --geometry-field <GEOMETRY-FIELD>                    Name of geometry field to use in sort
  --method <METHOD>                                    Geometry sorting algorithm. METHOD=hilbert|strtree (default: hilbert)
  --use-tempfile                                       Write features to a temporary file to avoid reading the entire input dataset into memory

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

πŸ¦‹ DESCRIPTION πŸ¦‹

so gdal vector sort takes your vector dataset and sorts the features by where their geometries actually are in space πŸ—ΊοΈ. you pick the sorting method with --method, and the options are Hilbert and Sort-Tile-Recursive (STRTree). both absolute bangers, ngl.

features with null or empty geometries? they get yeeted to the end of the sorted dataset. no geometry, no seat at the cool table, sorry bestie 😭

and the cutest part: this command can also be used as a step of gdal vector pipeline πŸ”₯ pipeline girlies stay winning.

NOTE: use of the STRtree algorithm requires a GDAL build against the GEOS library. no GEOS, no STRtree, periodt.

πŸŽ€ PROGRAM-SPECIFIC OPTIONS πŸŽ€

  • --geometry-field <GEOMETRY-FIELD> β€” the name of the geometry field by which features should be sorted. tell her which geometry is the main character πŸ’…
  • --method <METHOD> β€” specifies the sorting method. available options are:
    • hilbert β€” the default method, bestie. geometries are sorted according to the Hilbert code of the center point of their bounding box ✨
    • strtree β€” geometries are sorted by constructing a sort-tile-recursive tree using the GEOS library and performing a depth-first iteration 🌈
  • --use-tempfile β€” write the input features to a temporary file from which they can be read in sorted order. this avoids the need to load the entire input layer into memory πŸ§ βž‘οΈπŸ“„. lowkey a lifesaver when your dataset is enormous.

⭐ RETURN STATUS CODE ⭐

the program returns status code 0 in case of success, and non-zero in case of error. and listen β€” non-blocking errors emitted as warnings are considered as a successful execution, so don't come for her for those 🫢


🌈 EXAMPLES 🌈

πŸ’œ Example 1: Create a cloud-optimized Shapefile

$ gdal vector sort in.gpkg out.shp --method hilbert --lco SPATIAL_INDEX=YES

look at that. hilbert method, SPATIAL_INDEX=YES layer creation option, cloud-optimized shapefile. she ate and left no crumbs πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

Dan Baston <dbaston@gmail.com> πŸ’–


1998-2026


and that's the whole page bestie!! πŸŽ€ this manual page came to you from GDAL (the GDAL-VECTOR-SORT(1) one specifically, iykyk), dated Aug 18, 2026 πŸ“…βœ¨ go sort something spatially, you've got this πŸ¦‹πŸ’…

πŸ“¦ where this page comes from