GDAL-RASTER-ZONAL-STATS(1) GDAL GDAL-RASTER-ZONAL-STATS(1) (NAME) gdal-raster-zonal-stats - 3.12 . (SYNOPSIS) Usage: gdal raster zonal-stats [OPTIONS] Calculate raster zonal statistics Positional arguments: -i, --input Input raster 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: -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] -b, --band Input band(s) (1-based index) [may be repeated] --zones Dataset containing zone definitions [required] --zones-band Band from which zones should be read Mutually exclusive with --zones-layer --zones-layer Layer from which zones should be read Mutually exclusive with --zones-band --weights Weighting raster dataset --weights-band Band from which weights should be read (default: 1) --pixels Method to determine which pixels are included in stat calculation.. PIXELS=default|fractional|all-touched --stat Statistic(s) to compute for each zone. STAT=center_x|center_y|count|coverage|frac|max|max_center_x|max_center_y|mean|median|min|minority|min_center_x|min_center_y|mode|stdev|sum|unique|values|variance|variety|weighted_mean|weighted_stdev|weighted_sum|weighted_variance|weights [may be repeated] [required] --include-field Fields from polygon zones to include in output [may be repeated] --include-geom Include polygon zone geometry in the output --strategy For polygon zones, whether to iterate over input features or raster chunks. STRATEGY=feature|raster (default: feature) --chunk-size Maximum size of raster chunks read into memory (default: 5%) 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 raster zonal-stats (Zonal Statistics) -- () (Categorical) . [] ..UNINDENT . (CRS) . . (Reprojection) . (Pixel inclusion and weighting) . () . --pixels all-touched . --pixels fractional . GDAL 3.14 GEOS . (Supported stats) +------------------+--------------------------------------------+ | | | +------------------+--------------------------------------------+ |center_x | | | | x | | | | | | | | | | | | . | | | | | | | | | . | +------------------+--------------------------------------------+ |center_y | | | | y | | | | | | | | | | | | . | | | | | | | | | . | +------------------+--------------------------------------------+ |count | | | | | | | . | +------------------+--------------------------------------------+ |coverage | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |frac | | | | | | | | | | | | | | | | | | | | | | unique | | | . | +------------------+--------------------------------------------+ |max | | | | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |max_center_x | x | | | | | | | | | | | | | | | . | | | | | | | | | . | +------------------+--------------------------------------------+ |max_center_y | y | | | | | | | | | | | | | | | . | | | | | | | | | . | +------------------+--------------------------------------------+ |mean | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |min | | | | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |min_center_x | x | | | | | | | | | | | | | | | . | | | | | | | | | . | +------------------+--------------------------------------------+ |min_center_y | y | | | | | | | | | | | | | | | . | | | | | | | | | . | +------------------+--------------------------------------------+ |minority | | | | | | | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |mode | | | | | | | | | | | | | (/) | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |stdev | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |sum | | | | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |unique | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |values | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |variance | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |variety | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |weighted_frac | | | | | | | | | | | | | | | | | | | | | | | | | . | | | | | | | | | unique | | | . | +------------------+--------------------------------------------+ |weighted_mean | | | | | | | | | | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ |weighted_stdev | | | | stdev. | +------------------+--------------------------------------------+ |weighted_variance | | | | variance | +------------------+--------------------------------------------+ |weights | | | | | | | | | | | | | . | +------------------+--------------------------------------------+ gdal pipeline . (PROGRAM-SPECIFIC OPTIONS) --band, -b () . --chunk-size (Chunk) . (500 MB 2 GB ) ( 10%) . --include-field . . GDAL 3.13 "ALL" "NONE" . --include-geom . . 3.13 . --pixels : default all-touched fractional. --stat . --strategy (raster feature) . (--strategy feature) GDAL . . --strategy raster GDAL . ( --chunk-size .) . --weights . --weights-band . --zones . --zones-band --zones-layer . --zones-band . --zones-layer . (STANDARD OPTIONS) --append () . . --co, --creation-option = . GeoPackage . . . --formats . Vector drivers . . --if, --input-format / () . . . . . --lco, --layer-creation-option = . GeoPackage . . . --formats . Vector drivers . . --oo, --open-option = ( ). . -f, --of, --format, --output-format . : gdal --formats | grep vector | grep rw | sort --output-layer . . --output-open-option, --output-oo = 3.12 . ( ). . --overwrite . gdal . --overwrite-layer . --skip-errors 3.12 . () . . --update . --upsert 3.12 . --append OGRLayer::UpsertFeature() OGRLayer::CreateFeature() . : GPKG -- GeoPackage vector Elasticsearch: Geographically Encoded Objects for Elasticsearch MongoDBv3 ( upsert GDAL_DCAP_UPSERT ). / (upsert) FID ( FID ) . FID . GPKG / FID ( --unset-fid gdal vector edit FID ) (UNIQUE) . (RETURN STATUS CODE) 0 ( ). (EXAMPLES) : : gdal pipeline read dem.tif ! \ zonal-stats \ --zones [ read points.geojson ! buffer 200 ] \ --stat mean ! \ write \ --output-format CSV \ --output /vsistdout/ ``_PIPE_``: gdal pipeline read points.geojson ! \ buffer 200 ! \ zonal-stats \ --input dem.tif --zones _PIPE_ \ --stat mean ! \ write \ --output-format CSV \ --output /vsistdout/ : gdal pipeline read dem.tif ! zonal-stats \ --zones watersheds.shp \ --stat max_center_x \ --stat max_center_y ! \ make-point \ --x max_center_x \ --y max_center_y \ --output-crs EPSG:4326 ! \ write out.geojson (AUTHOR) Dan Baston (COPYRIGHT) 1998-2026 August 18, 2026 GDAL-RASTER-ZONAL-STATS(1)