1GDAL_RASTERIZE(1)                    GDAL                    GDAL_RASTERIZE(1)
2
3
4

NAME

6       gdal_rasterize - Burns vector geometries into a raster.
7

SYNOPSIS

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/UInt64/Int64/Float32/Float64/
16                      CInt16/CInt32/CFloat32/CFloat64}]
17              [-optim {[AUTO]/VECTOR/RASTER}] [-q]
18              <src_datasource> <dst_filename>
19

DESCRIPTION

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
104              GDALCreateGenImgProjTransformer2(). This is used when converting
105              geometries coordinates to target raster pixel space. For example
106              this can be 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.  Alignment means that xmin /
137              resx, ymin / resy, xmax / resx and ymax / resy are integer  val‐
138              ues.
139
140       -ts <width> <height>
141              Set  output  file size in pixels and lines. Note that -ts cannot
142              be used with -tr
143
144       -ot <type>
145              Force the output bands to be of the  indicated  data  type.  De‐
146              faults to Float64
147
148       -optim {[AUTO]/VECTOR/RASTER}}
149              Force  the  algorithm  used  (results are identical). The raster
150              mode is used in most cases and optimise  read/write  operations.
151              The vector mode is useful with a decent amount of input features
152              and optimise the CPU use. That mode have to be used  with  tiled
153              images  to  be efficient. The auto mode (the default) will chose
154              the algorithm based on input and output properties.
155
156              New in version 2.3.
157
158
159       -q     Suppress progress monitor and other non-error output.
160
161       <src_datasource>
162              Any OGR supported readable datasource.
163
164       <dst_filename>
165              The GDAL supported output file.  Must support  update  mode  ac‐
166              cess.   This  file will be created (or overwritten if it already
167              exists):option:-of, -a_nodata, -init,  -a_srs,  -co,  -te,  -tr,
168              -tap, -ts, or -ot options are used.
169
170       The  program  create  a  new  target  raster image when any of the -of,
171       -a_nodata, -init, -a_srs, -co, -te, -tr, -tap, -ts, or -ot options  are
172       used.   The  resolution  or size must be specified using the -tr or -ts
173       option for all new rasters.  The target raster will be  overwritten  if
174       it already exists and any of these creation-related options are used.
175

C API

177       This utility is also callable from C with GDALRasterize().
178
179       New in version 2.1.
180
181

EXAMPLE

183       The  following  would burn all polygons from mask.shp into the RGB TIFF
184       file work.tif with the color red (RGB = 255,0,0).
185
186          gdal_rasterize -b 1 -b 2 -b 3 -burn 255 -burn 0 -burn 0 -l mask mask.shp work.tif
187
188       The following would burn all "class A" buildings into the output eleva‐
189       tion file, pulling the top elevation from the ROOF_H attribute.
190
191          gdal_rasterize -a ROOF_H -where "class='A'" -l footprints footprints.shp city_dem.tif
192
193       The  following  would  burn  all polygons from footprint.shp into a new
194       1000x1000 rgb TIFF as the color red.  Note that -b is not used; the or‐
195       der of the -burn options determines the bands of the output raster.
196
197          gdal_rasterize -burn 255 -burn 0 -burn 0 -ot Byte -ts 1000 1000 -l footprints footprints.shp mask.tif
198

AUTHOR

200       Frank Warmerdam <warmerdam@pobox.com>
201
203       1998-2023
204
205
206
207
208                                 Apr 17, 2023                GDAL_RASTERIZE(1)
Impressum