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