GDAL-VECTOR-RASTERIZE(1) GDAL GDAL-VECTOR-RASTERIZE(1) NAME gdal-vector-rasterize - Burn vector geometries into a raster Added in version 3.11. SYNOPSIS Usage: gdal vector rasterize [OPTIONS] Burns vector geometries into a raster. Positional arguments: -i, --input Input vector dataset [required] -o, --output Output raster dataset [required] Common Options: -h, --help Display help message and exit --json-usage Display usage as JSON document and exit --config = Configuration option [may be repeated] --progress Display progress bar Options: -f, --of, --format, --output-format Output format --co, --creation-option = Creation option [may be repeated] -b, --band The band(s) to burn values into (1-based index) [may be repeated] --invert Invert the rasterization --all-touched Enables the ALL_TOUCHED rasterization option --burn Burn value [may be repeated] -a, --attribute-name Attribute name --3d Indicates that a burn value should be extracted from the Z values of the feature --add Add to existing raster -l, --layer, --layer-name Layer name Mutually exclusive with --sql --where SQL where clause --sql SQL select statement Mutually exclusive with --layer-name --dialect SQL dialect --nodata Assign a specified nodata value to output bands --init Pre-initialize output bands with specified value [may be repeated] --crs Override the projection for the output file --transformer-option = Set a transformer option suitable to pass to GDALCreateGenImgProjTransformer2 [may be repeated] --extent ,,, Set the target georeferenced extent [4 values] --resolution , Set the target resolution [2 values] Mutually exclusive with --size --tap, --target-aligned-pixels (target aligned pixels) Align the coordinates of the extent of the output file to the values of the resolution --size , Set the target size in pixels and lines [2 values] Mutually exclusive with --resolution --ot, --datatype, --output-data-type Output data type. OUTPUT-DATA-TYPE=Byte|Int8|UInt16|Int16|UInt32|Int32|UInt64|Int64|CInt16|CInt32|Float16|Float32|Float64|CFloat32|CFloat64 --optimization Force the algorithm used (results are identical). OPTIMIZATION=AUTO|RASTER|VECTOR (default: AUTO) --update Whether to open existing dataset in update mode --overwrite Whether overwriting existing output is allowed Advanced Options: --oo, --open-option = Open options [may be repeated] --if, --input-format Input formats [may be repeated] DESCRIPTION gdal vector rasterize burns vector geometries into a raster. The following options are available: Standard options -f, --of, --format, --output-format Which output raster format to use. Allowed values may be given by gdal --formats | grep raster | grep rw | sort --co = 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. --band, -b The band(s) to burn values into. May be repeated. --invert Invert rasterization. Burn the fixed burn value, or the burn value associated with the first feature into all parts of the image not inside the provided polygon. NOTE: When the vector features contain a polygon nested within another polygon (like an island in a lake), GDAL must be built against GEOS to get correct results. --all-touched Enables the ALL_TOUCHED rasterization option. NOTE: When this option is enabled, the order of the input features (lines or polygons) can affect the results. When two features touch each other, the last one (i.e. topmost) will determine the burned pixel value at the edge. You may wish to use the --sql option to reorder the features (ORDER BY) to achieve a more predictable result. --burn Burn value. May be repeated. -a, --attribute-name Attribute name. --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, works properly only if they are flat (same Z value for all vertices). --add Instead of burning a new value, this adds the new value to the existing raster, implies --update. Suitable for heatmaps for instance. -l, --layer, --layer-name 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 -sql option must be specified (not both). --where An optional SQL WHERE style query expression to be applied to select features to burn in from the input layer(s). --sql |@ An SQL statement to be evaluated against the datasource to produce a virtual layer of features to be burned in. The @filename syntax can be used to indicate that the content is in the pointed filename. --dialect SQL dialect. By default the native SQL of an RDBMS is used when using gdal vector sql. If using sql as a step of gdal vector pipeline, this is only true if the step preceding sql is read, otherwise the OGRSQL dialect is used. If a datasource does not support SQL natively, the default is to use the OGRSQL dialect, which can also be specified with any data source. The SQL SQLite dialect dialect can be chosen with the SQLITE and INDIRECT_SQLITE dialect values, and this can be used with any data source. Overriding the default dialect may be beneficial because the capabilities of the SQL dialects vary. What SQL dialects a driver supports can be checked with "gdal vector info". Supported dialects can be checked with gdal vector info. For example: $ gdal vector info --format "PostgreSQL" Supported SQL dialects: NATIVE OGRSQL SQLITE $ gdal vector info --format "ESRI Shapefile" Supported SQL dialects: OGRSQL SQLITE --nodata Assign a specified nodata value to output bands. --init Pre-initialize output bands with specified value. May be repeated. --crs 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, no reprojection of features from the CRS of the input vector to the specified CRS of the output raster, so use only this option to correct an invalid source CRS. The may be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n or a file containing the WKT. --transformer-option = set a transformer option suitable to pass to GDALCreateGenImgProjTransformer2(). This is used when converting geometries coordinates to target raster pixel space. For example this can be used to specify RPC related transformer options. --extent ,,, 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. --resolution , Set target resolution. The values must be expressed in georeferenced units. Both must be positive values. Note that --resolution cannot be used with --size. --tap, --target-aligned-pixels (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. Alignment means that xmin / resx, ymin / resy, xmax / resx and ymax / resy are integer values. --size , Set output file size in pixels and lines. Note that --size cannot be used with --resolution. --ot, --datatype, --output-data-type Force the output bands to be of the indicated data type. Defaults to Float64, unless the attribute field to burn is of type Int64, in which case Int64 is used for the output raster data type if the output driver supports it. --optimization Force the algorithm used (results are identical). The raster mode is used in most cases and optimise read/write operations. The vector mode is useful with a decent amount of input features and optimise the CPU use. That mode have to be used with tiled images to be efficient. The auto mode (the default) will chose the algorithm based on input and output properties. --update Whether to open existing dataset in update mode. --overwrite Whether overwriting existing output is allowed. Advanced options --oo = Dataset open option (format specific). May be repeated. --if 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. EXAMPLES Example 1: Burn a shapefile into a raster 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 vector rasterize -b 1,2,3 --burn 255,0,0 -l mask mask.shp work.tif Example 2: The following would burn all "class A" buildings into the output elevation file, pulling the top elevation from the ROOF_H attribute. Burn a shapefile into a raster using a specific where condition to select features gdal vector rasterize -a ROOF_H --where "class='A'" -l footprints footprints.shp city_dem.tif Example 3: The following would burn all polygons from footprint.shp into a new 1000x1000 rgb TIFF as the color red. NOTE: -b is not used; the order of the --burn options determines the bands of the output raster. gdal vector rasterize --burn 255,0,0 --ot Byte --size 1000,1000 -l footprints footprints.shp mask.tif AUTHOR Alessandro Pasotti COPYRIGHT 1998-2025 May 6, 2025 GDAL-VECTOR-RASTERIZE(1)