GDAL-VECTOR-SORT(1) GDAL GDAL-VECTOR-SORT(1) NAME gdal-vector-sort - Spatially sort a vector dataset Added in version 3.13. SYNOPSIS Usage: gdal vector sort [OPTIONS] Spatially order the features in a layer Positional arguments: -i, --input Input vector datasets [required] [not available in pipelines] -o, --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 = 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 name(s) [may be repeated] [not available in pipelines] -f, --of, --format, --output-format Output format ("GDALG" allowed) [not available in pipelines] --co, --creation-option = Creation option [may be repeated] [not available in pipelines] --lco, --layer-creation-option = 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 name [not available in pipelines] --skip-errors Skip errors when writing features [not available in pipelines] --geometry-field Name of geometry field to use in sort --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 formats [may be repeated] [not available in pipelines] --oo, --open-option = Open options [may be repeated] [not available in pipelines] --output-oo, --output-open-option = Output open options [may be repeated] [not available in pipelines] --upsert Upsert features (implies 'append') [not available in pipelines] Mutually exclusive with --append DESCRIPTION gdal vector sort sorts the features in a vector dataset according to the position of its geometries. The sorting method can be specified via --method, with Hilbert and Sort-Tile-Recursive (STRTree) algorithms available. Features that have null or empty geometries will be placed at the end of the sorted dataset. This command can also be used as a step of gdal vector pipeline. NOTE: Use of the STRtree algorithm requires a GDAL build against the GEOS library. PROGRAM-SPECIFIC OPTIONS --geometry-field The name of the geometry field by which features should be sorted. --method Specifies the sorting method. Available options are: o hilbert : default method. Geometries are sorted according to the Hilbert code of the center point of their bounding box o 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. Avoids the need to load the entire input layer into memory. 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: Create a cloud-optimized Shapefile $ gdal vector sort in.gpkg out.shp --method hilbert --lco SPATIAL_INDEX=YES AUTHOR Dan Baston COPYRIGHT 1998-2026 May 8, 2026 GDAL-VECTOR-SORT(1)