1GDAL_RASTERIZE(1) GDAL GDAL_RASTERIZE(1)
2
3
4
6 gdal_rasterize - Burns vector geometries into a raster.
7
9 gdal_rasterize [-b band]* [-i] [-at]
10 [-oo NAME=VALUE]*
11 {[-burn value]* | [-a attribute_name] | [-3d]} [-add]
12 [-l layername]* [-where expression] [-sql select_statement|@filename]
13 [-dialect dialect] [-of format] [-a_srs srs_def] [-to NAME=VALUE]*
14 [-co "NAME=VALUE"]* [-a_nodata value] [-init value]*
15 [-te xmin ymin xmax ymax] [-tr xres yres] [-tap] [-ts width height]
16 [-ot {Byte/Int8/Int16/UInt16/UInt32/Int32/UInt64/Int64/Float32/Float64/
17 CInt16/CInt32/CFloat32/CFloat64}]
18 [-optim {[AUTO]/VECTOR/RASTER}] [-q]
19 <src_datasource> <dst_filename>
20
22 This program burns vector geometries (points, lines, and polygons) into
23 the raster band(s) of a raster image. Vectors are read from OGR sup‐
24 ported vector formats.
25
26 Note that on the fly reprojection of vector data to the coordinate sys‐
27 tem of the raster data is only supported since GDAL 2.1.0.
28
29 -b <band>
30 The band(s) to burn values into. Multiple -b arguments may be
31 used to burn into a list of bands. The default is to burn into
32 band 1. Not used when creating a new raster.
33
34 -i Invert rasterization. Burn the fixed burn value, or the burn
35 value associated with the first feature into all parts of the
36 image not inside the provided polygon.
37
38 -at Enables the ALL_TOUCHED rasterization option so that all pixels
39 touched by lines or polygons will be updated, not just those on
40 the line render path, or whose center point is within the poly‐
41 gon. Defaults to disabled for normal rendering rules.
42
43 -burn <value>
44 A fixed value to burn into a band for all objects. A list of
45 -burn options can be supplied, one per band being written to.
46
47 -a <attribute_name>
48 Identifies an attribute field on the features to be used for a
49 burn-in value. The value will be burned into all output bands.
50
51 -3d Indicates that a burn value should be extracted from the "Z"
52 values of the feature. Works with points and lines (linear in‐
53 terpolation along each segment). For polygons, works properly
54 only if the are flat (same Z value for all vertices).
55
56 -add Instead of burning a new value, this adds the new value to the
57 existing raster. Suitable for heatmaps for instance.
58
59 -l <layername>
60 Indicates the layer(s) from the datasource that will be used for
61 input features. May be specified multiple times, but at least
62 one layer name or a -sql option must be specified.
63
64 -where <expression>
65 An optional SQL WHERE style query expression to be applied to
66 select features to burn in from the input layer(s).
67
68 -sql <select_statement>
69 An SQL statement to be evaluated against the datasource to pro‐
70 duce a virtual layer of features to be burned in. Starting with
71 GDAL 3.7, the @filename syntax can be used to indicate that the
72 content is in the pointed filename.
73
74 -dialect <dialect>
75 SQL dialect. In some cases can be used to use (unoptimized) OGR
76 SQL instead of the native SQL of an RDBMS by passing OGRSQL. The
77 "SQLITE" dialect can also be used with any datasource.
78
79 New in version 2.1.
80
81
82 -of <format>
83 Select the output format. Starting with GDAL 2.3, if not speci‐
84 fied, the format is guessed from the extension (previously was
85 GTiff). Use the short format name.
86
87 -a_nodata <value>
88 Assign a specified nodata value to output bands.
89
90 -init <value>
91 Pre-initialize the output image bands with these values. How‐
92 ever, it is not marked as the nodata value in the output file.
93 If only one value is given, the same value is used in all the
94 bands.
95
96 -a_srs <srs_def>
97 Override the projection for the output file. If not specified,
98 the projection of the input vector file will be used if avail‐
99 able. When using this option, no reprojection of features from
100 the SRS of the input vector to the specified SRS of the output
101 raster, so use only this option to correct an invalid source
102 SRS. The <srs_def> may be any of the usual GDAL/OGR forms, com‐
103 plete WKT, PROJ.4, EPSG:n or a file containing the WKT.
104
105 -to NAME=VALUE
106 set a transformer option suitable to pass to
107 GDALCreateGenImgProjTransformer2(). This is used when converting
108 geometries coordinates to target raster pixel space. For example
109 this can be used to specify RPC related transformer options.
110
111 New in version 2.3.
112
113
114 -co <NAME=VALUE>
115 Many formats have one or more optional creation options that can
116 be used to control particulars about the file created. For in‐
117 stance, the GeoTIFF driver supports creation options to control
118 compression, and whether the file should be tiled.
119
120 The creation options available vary by format driver, and some
121 simple formats have no creation options at all. A list of op‐
122 tions supported for a format can be listed with the --formats
123 command line option but the documentation for the format is the
124 definitive source of information on driver creation options.
125 See Raster drivers format specific documentation for legal cre‐
126 ation options for each format.
127
128 -te <xmin> <ymin> <xmax> <ymax>
129 Set georeferenced extents. The values must be expressed in geo‐
130 referenced units. If not specified, the extent of the output
131 file will be the extent of the vector layers.
132
133 -tr <xres> <yres>
134 Set target resolution. The values must be expressed in georefer‐
135 enced units. Both must be positive values.
136
137 -tap (target aligned pixels) Align the coordinates of the extent of
138 the output file to the values of the -tr, such that the aligned
139 extent includes the minimum extent. Alignment means that xmin /
140 resx, ymin / resy, xmax / resx and ymax / resy are integer val‐
141 ues.
142
143 -ts <width> <height>
144 Set output file size in pixels and lines. Note that -ts cannot
145 be used with -tr
146
147 -ot <type>
148 Force the output bands to be of the indicated data type. De‐
149 faults to Float64
150
151 -optim {[AUTO]/VECTOR/RASTER}}
152 Force the algorithm used (results are identical). The raster
153 mode is used in most cases and optimise read/write operations.
154 The vector mode is useful with a decent amount of input features
155 and optimise the CPU use. That mode have to be used with tiled
156 images to be efficient. The auto mode (the default) will chose
157 the algorithm based on input and output properties.
158
159 New in version 2.3.
160
161
162 -oo <NAME=VALUE>
163 New in version 3.7.
164
165
166 Source dataset open option (format specific)
167
168 -q Suppress progress monitor and other non-error output.
169
170 <src_datasource>
171 Any OGR supported readable datasource.
172
173 <dst_filename>
174 The GDAL supported output file. Must support update mode ac‐
175 cess. This file will be created (or overwritten if it already
176 exists):option:-of, -a_nodata, -init, -a_srs, -co, -te, -tr,
177 -tap, -ts, or -ot options are used.
178
179 The program create a new target raster image when any of the -of,
180 -a_nodata, -init, -a_srs, -co, -te, -tr, -tap, -ts, or -ot options are
181 used. The resolution or size must be specified using the -tr or -ts
182 option for all new rasters. The target raster will be overwritten if
183 it already exists and any of these creation-related options are used.
184
186 This utility is also callable from C with GDALRasterize().
187
188 New in version 2.1.
189
190
192 The following would burn all polygons from mask.shp into the RGB TIFF
193 file work.tif with the color red (RGB = 255,0,0).
194
195 gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l mask mask.shp work.tif
196
197 The following would burn all "class A" buildings into the output eleva‐
198 tion file, pulling the top elevation from the ROOF_H attribute.
199
200 gdal_rasterize -a ROOF_H -where "class='A'" -l footprints footprints.shp city_dem.tif
201
202 The following would burn all polygons from footprint.shp into a new
203 1000x1000 rgb TIFF as the color red. Note that -b is not used; the or‐
204 der of the -burn options determines the bands of the output raster.
205
206 gdal_rasterize -burn 255 -burn 0 -burn 0 -ot Byte -ts 1000 1000 -l footprints footprints.shp mask.tif
207
209 Frank Warmerdam <warmerdam@pobox.com>
210
212 1998-2023
213
214
215
216
217 Oct 30, 2023 GDAL_RASTERIZE(1)