GDAL_POLYGONIZE(1)
π GDAL_POLYGONIZE(1) β the glow-up β¨
okay so bestie, welcome to the GDAL_POLYGONIZE(1) page π
this is the one that turns your raster into a whole polygon layer, and honestly? it eats.
πΈ NAME πΈ
gdal_polygonize β produces a polygon feature layer from a raster. that's it, that's the whole job, and she does it flawlessly π«Ά
β¨ SYNOPSIS β¨
gdal_polygonize [--help] [--help-general]
[-8] [-o <name>=<value>]... [-nomask]
[-mask <filename>] <raster_file> [-b <band>]
[-q] [-f <ogr_format>] [-lco <name>=<value>]...
[-overwrite] <out_file> [<layer>] [<fieldname>]
π¦ DESCRIPTION π¦
so what she actually does: she makes vector polygons for every connected region of pixels in the raster that share a common pixel value π and each of those polygons gets an attribute that tells you the pixel value of that polygon. so the polygons know where they came from. main character behaviour fr.
you can also hand her a raster mask, which decides which pixels are even eligible for processing (no mask, no entry π ).
if the output vector datasource doesn't exist yet, she'll just create it. if it does already exist? she'll try to append to it. flexible queen.
she's built on top of the :GDALPolygonize() function, which is where the nitty-gritty details of the algorithm live if you're the type who reads the source (respect).
NOTE: gdal_polygonize is a Python utility, and is only available if GDAL Python bindings are available. no bindings, no polygoniβ π
TIP: Equivalent in new"gdal"command line interface: Seegdal raster polygonize.
ok now the options, buckle up π
--helpβ shows you this help message and then dips. exit, stage left.--help-generalβ gives you a brief usage message for the generic GDAL commandline options and exits. the generic ones, not the specific ones, don't get it twisted.-8β use 8 connectedness. the default is 4 connectedness. so like, do you want your pixels to know their diagonal neighbours too? yes?-8. iconic.-nomaskβ do not use the default validity mask for the input band (stuff like nodata, or alpha masks). girl said no mask today π-mask <filename>β use the first band of the specified file as a validity mask (zero is invalid, non-zero is valid). if you don't specify one, the default validity mask for the input band (again: nodata, alpha masks, etc.) gets used β unless you passed-nomask, obviously.<raster_file>β the source raster file from which the polygons are derived. the raw material. the blueprint. the vibe check.-b <band>β the band on<raster_file>to build the polygons from. you can also set the value to"mask"to say "use the mask band of the first band", or"mask,band_number"for the mask of a specified band. very β¨choose your own adventureβ¨ of her.-f <ogr_format>β pick the output format. if you don't, the format gets guessed from the extension. use the short format name, bestie, not the long one.-o <NAME>=<VALUE>β Added in version 3.7. polygonize option. go read the:GDALPolygonize()documentation for the deets, iykyk.-lco <NAME>=<VALUE>β Added in version 3.7. layer creation option (format specific).-overwriteβ Added in version 3.8. overwrite the output layer if it already exists. no hesitation, no mercy, periodt.<out_file>β the destination vector file to which the polygons will be written. the final home for your polygons π‘<layer>β the name of the layer created to hold the polygon features.<fieldname>β the name of the field to create. defaults to"DN", in case you were wondering.-qβ the script runs in quiet mode. the progress monitor is suppressed and routine messages are not displayed. silent. mysterious. lowkey terrifying but in a chic way π
π RETURN STATUS CODE π
she returns status code 0 when it's a success girlie, and non-zero when something went wrong. and heads up: non-blocking errors emitted as warnings are considered as a successful execution β so a lil warning noise does not a failure make π«Ά
π AUTHOR π
Frank Warmerdam <warmerdam@pobox.com>
π COPYRIGHT π
1998-2026
and that's the whole page bestie!! go polygonize something gorgeous ππ
xoxo, your GDAL_POLYGONIZE(1) page β GDAL, dated Aug 18, 2026, signing off β¨π¦π
π¦ 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