GDAL-RASTER-POLYGONIZE(1)

πŸ’… NAME πŸ’…

okay so bestie, welcome to gdal-raster-polygonize β€” the GDAL manual page for it, mwah. What does it do?? It creates a polygon feature dataset from a raster band. that's it, that's the whole vibe. ✨

oh and p.s. it was Added in version 3.11. πŸŽ€


✨ SYNOPSIS ✨

Usage: gdal raster polygonize [OPTIONS] <INPUT> <OUTPUT>

Create a polygon feature dataset from a raster band.

Positional arguments:
  -i, --input <INPUT>                                  Input raster 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:
  -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]
  --output-layer <OUTPUT-LAYER>                        Output layer name
  -b, --band <BAND>                                    Input band (1-based index) (default: 1)
  --attribute-name <ATTRIBUTE-NAME>                    Name of the field with the pixel value (default: DN)
  -c, --connect-diagonal-pixels                        Consider diagonal pixels as connected

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]

🌸 DESCRIPTION 🌸

ok so here's the tea. gdal raster polygonize creates vector polygons for all connected regions of pixels in the raster sharing a common pixel value. every polygon it makes gets an attribute that tells you the pixel value of that polygon, iconic behavior fr fr. and pixels set to the NoData value, or masked with an external mask band?? yeah they don't get included in processing, sorry babe, they're not invited. πŸ™ˆ

good news though: the utility can create the output vector dataset if it does not already exist, and if it does exist, it may append to it. flexible queen. πŸ‘‘

also, for the nerds who want the lore (affectionate): this utility is based on the :GDALPolygonize() function, which has additional details on the algorithm. go read it if you're curious, i support it. πŸ’œ

and Since GDAL 3.12, this algorithm can be part of a gdal pipeline. slay.

πŸ–ΌοΈ there's a figure that goes here: Polygonization of a 3x3 raster input. The middle figure shows the default behavior, where separate polygons are created for pixel regions that are connected only to a diagonal neighbor. In the figure on the right, --connect-diagonal-pixels has been specified, and a single polygon has been created for pixels with value 4..

oh and also β€” Added in version 3.12. πŸŽ€


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

so this program supports serializing the command line as a JSON file using the GDALG output format. once you've got that file, you can open it as a vector dataset using the GDALG: GDAL Streamed Algorithm driver, and it'll apply the specified pipeline in a on-the-fly / streamed way. streaming?? we love her. ✨

⚠️ NOTE: however, this algorithm is not natively streaming compatible. consequently, a in-memory temporary dataset will be generated, which may cause significant processing time at opening. so like... it's giving slow. plan accordingly bestie. 😭

πŸ’– PROGRAM-SPECIFIC OPTIONS πŸ’–

  • --attribute-name <ELEVATION-NAME> β€” the name of the field to create (defaults to "DN"). name your baby whatever u want.
  • -b, --band <BAND> β€” picks a particular band to polygonize. defaults to band 1. (yes, the placeholder is <BAND>, she contains multitudes.)
  • -c, --connect-diagonal-pixels β€” consider diagonal pixels (pixels at the corners) as connected. the default behavior is to only consider pixels that are touching the edges as connected, which is the same as 4-connectivity. when this option is selected, the algorithm will also consider pixels at the corners as connected, which is the same as 8-connectivity. two vibes, one flag. πŸ”₯
  • --nln, --output-layer <OUTPUT-LAYER> β€” provides a name for the output vector layer. defaults to "polygonize". cute name tbh.

πŸ‘‘ STANDARD OPTIONS πŸ‘‘

  • --append β€” whether appending features to existing layer(s) is allowed. this also creates the output dataset if it does not exist yet. two birds, one slay.
  • --co, --creation-option <NAME>=<VALUE> β€” many formats have one or more optional creation options that can be used to control particulars about the file created. for instance, the GeoTIFF driver supports creation options to control compression, and whether the file should be tiled.

may be repeated.

the 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 Raster drivers format specific documentation for legal creation options for each format. ✨

  • --if, --input-format <format> β€” format/driver name to be attempted to open the input file(s). it is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate 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. in particular, some drivers have requirements on file extensions.

may be repeated.

  • --lco, --layer-creation-option <NAME>=<VALUE> β€” many formats have one or more optional layer creation options that can be used to 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.

note that layer creation options are different from dataset creation options. don't confuse them bestie, i'm begging. 😭
  • -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. iconic little pipeline, iykyk. πŸ’…
  • --oo, --open-option <NAME>=<VALUE> β€” dataset open option (format specific).

may be repeated.

  • --output-open-option, --output-oo <NAME>=<VALUE> β€” Added in version 3.12.

dataset open option for output dataset (format specific).

may be repeated.

  • --overwrite β€” allow program to overwrite existing target file or dataset. otherwise, by default, gdal errors out if the target file or dataset already exists. so like, be brave on purpose, not on accident. πŸ”₯
  • --overwrite-layer β€” whether overwriting the existing output vector layer is allowed.
  • --update β€” whether to open an existing output dataset in update mode.

🌈 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 lil warning is not a crisis, periodt. 🫢


πŸ“ EXAMPLES πŸ“

example 1: create a shapefile with polygons for the connected regions of band 1 of the input GeoTIFF.

gdal raster polygonize input.tif polygonize.shp

that's it. one line. she ate and left no crumbs. πŸ‘‘


🧚 AUTHOR 🧚

Even Rouault <even.rouault@spatialys.com>


1998-2026


okay bestie that's the whole page, you're fully caught up and certified in raster polygonization now πŸ’œ and hey β€” this was the GDAL-RASTER-POLYGONIZE(1) page from the GDAL manual, dated Aug 18, 2026. go make some polygons, ily, bye!! βœ¨πŸ¦‹πŸŒΈπŸŽ€πŸ’…

πŸ“¦ where this page comes from