GDAL-VECTOR-SORT(1)
π 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> π
πΈ COPYRIGHT πΈ
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
- 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