GDAL_RASTERIZE(1)
π GDAL_RASTERIZE(1) β the GDAL girlies' edition π
okay so bestie, welcome to gdal_rasterize, straight out of the GDAL manual π this one's a little icon and it does exactly one thing but it does it so well. let's get into it β¨
β¨ NAME β¨
gdal_rasterize β burns vector geometries into a raster. that's it, that's the whole vibe π₯
πΈ SYNOPSIS πΈ
gdal_rasterize [-b band]* [-i] [-at]
{[-burn value]* | [-a attribute_name] | [-3d]} [-add]
[-l layername]* [-where expression] [-sql select_statement]
[-dialect dialect] [-of format] [-a_srs srs_def] [-to NAME=VALUE]*
[-co "NAME=VALUE"]* [-a_nodata value] [-init value]*
[-te xmin ymin xmax ymax] [-tr xres yres] [-tap] [-ts width height]
[-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
CInt16/CInt32/CFloat32/CFloat64}]
[-optim {[AUTO]/VECTOR/RASTER}] [-q]
<src_datasource> <dst_filename>
π¦ DESCRIPTION π¦
This program burns vector geometries β points, lines, and polygons β into the raster band(s) of a raster image. Vectors are read from OGR supported vector formats. literally taking your shapes and stamping them into pixels, no cap π«Ά
Heads up bestie: on the fly reprojection of vector data to the coordinate system of the raster data is only supported since GDAL 2.1.0. so if you're on something ancient... that's a no from me π
π OPTIONS π
-b<band>β the band(s) to burn values into. you can pass multiple-barguments to burn into a whole list of bands. default is to burn into band 1. this one's not used when you're creating a new raster π-iβ invert rasterization. burn the fixed burn value, or the burn value associated with the first feature, into all parts of the image that are not inside the provided polygon. opposite day, and it ate β¨-atβ enables the ALL_TOUCHED rasterization option, so all pixels touched by lines or polygons get updated β not just those on the line render path, or whose center point is within the polygon. defaults to disabled for normal rendering rules. so generous of her π-burn<value>β a fixed value to burn into a band for all objects. you can supply a whole list of-burnoptions, one per band being written to. π-a<attribute_name>β identifies an attribute field on the features to be used for a burn-in value. the value gets burned into all output bands. queen behavior π-3dβ indicates that a burn value should be extracted from the "Z" values of the feature. works with points and lines (linear interpolation along each segment). for polygons, it works properly only if they are flat (same Z value for all vertices). so like... no 3D drama on the polygons pls π-addβ instead of burning a new value, this adds the new value to the existing raster. suitable for heatmaps for instance. stacking, layering, main character energy π₯-l<layername>β indicates the layer(s) from the datasource that will be used for input features. may be specified multiple times, but at least one layer name or a-sqloption must be specified. pick your girls π-where<expression>β an optional SQL WHERE style query expression, applied to select which features to burn in from the input layer(s). filter the guest list, iykyk π-sql<select_statement>β an SQL statement to be evaluated against the datasource to produce a virtual layer of features to be burned in. build-a-bear but make it queries π§-dialect<dialect>β SQL dialect. in some cases it can be used to use (unoptimized) OGR SQL instead of the native SQL of an RDBMS by passingOGRSQL. the"SQLITE"dialect can also be used with any datasource.
New in version 2.1. β
-of<format>β select the output format. starting with GDAL 2.3, if it's not specified, the format is guessed from the extension (previously it wasGTiff). use the short format name, bestie β¨-a_nodata<value>β assign a specified nodata value to output bands. the "nobody's home" pixel π-init<value>β pre-initialize the output image bands with these values. however, it is not marked as the nodata value in the output file. if only one value is given, the same value is used in all the bands. so close to nodata but not quite π«Ά-a_srs<srs_def>β override the projection for the output file. if not specified, the projection of the input vector file will be used if available. when using this option, there is no reprojection of features from the SRS of the input vector to the specified SRS of the output raster β so use only this option to correct an invalid source SRS. the<srs_def>may be any of the usual GDAL/OGR forms: complete WKT, PROJ.4,EPSG:n, or a file containing the WKT. π-toNAME=VALUEβ set a transformer option suitable to pass toGDALCreateGenImgProjTransformer2(). this is used when converting geometries coordinates to target raster pixel space. for example, it can be used to specify RPC related transformer options.
New in version 2.3. β
-co<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.
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. π
-te<xmin><ymin><xmax><ymax>β set georeferenced extents. the values must be expressed in georeferenced units. if not specified, the extent of the output file will be the extent of the vector layers. boundaries, set π-tr<xres><yres>β set target resolution. the values must be expressed in georeferenced units. both must be positive values. no negativity on this account bestie π«-tapβ (target aligned pixels) align the coordinates of the extent of the output file to the values of the-tr, such that the aligned extent includes the minimum extent. everything lines up, it's giving grid πΈ-ts<width><height>β set output file size in pixels and lines. note that-tscannot be used with-tr. pick a lane π-ot<type>β force the output bands to be of the indicated data type. defaults toFloat64.-optim {[AUTO]/VECTOR/RASTER}}β force the algorithm used (results are identical). the raster mode is used in most cases and optimises read/write operations. the vector mode is useful with a decent amount of input features and optimises the CPU use β that mode has to be used with tiled images to be efficient. the auto mode (the default) will chose the algorithm based on input and output properties.
New in version 2.3. β
-qβ suppress progress monitor and other non-error output. quiet luxury, lowkey π€«<src_datasource>β any OGR supported readable datasource. bring me your shapes π¦<dst_filename>β the GDAL supported output file. must support update mode access. this file will be created (or overwritten if it already exists):-of,-a_nodata,-init,-a_srs,-co,-te,-tr,-tap,-ts, or-otoptions are used.
The program creates a new target raster image when any of the -of, -a_nodata, -init, -a_srs, -co, -te, -tr, -tap, -ts, or -ot options are used. the resolution or size must be specified using the -tr or -ts option for all new rasters. the target raster will be overwritten if it already exists and any of these creation-related options are used. π protect your files bestie, she does not ask twice
π§ C API π§
This utility is also callable from C with GDALRasterize().
New in version 2.1. β
π EXAMPLE π
The following would burn all polygons from mask.shp into the RGB TIFF file work.tif with the color red (RGB = 255,0,0).
gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l mask mask.shp work.tif
The following would burn all "class A" buildings into the output elevation file, pulling the top elevation from the ROOF_H attribute.
gdal_rasterize -a ROOF_H -where 'class="A"' -l footprints footprints.shp city_dem.tif
The following would burn all polygons from footprint.shp into a new 1000x1000 rgb TIFF as the color red. note that -b is not used; the order of the -burn options determines the bands of the output raster. iconic tbh π₯
gdal_rasterize -burn 255 -burn 0 -burn 0 -ot Byte -ts 1000 1000 -l footprints footprints.shp mask.tif
π AUTHOR π
Frank Warmerdam <warmerdam@pobox.com> β king behavior honestly π
π COPYRIGHT π
1998-2026
okay that's the whole page bestie, you're officially a rasterizer girlie now π this was GDAL's GDAL_RASTERIZE(1) from Jan 08, 2026 β go burn some polygons, slay, and remember: always back up before you overwrite πβ¨π«Ά
π¦ where this page comes from
- epel 9: gdal3.4 3.4.3-5.el9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms