1GDALWARP(1) GDAL GDALWARP(1)
2
3
4
6 gdalwarp - Image reprojection and warping utility.
7
9 gdalwarp [--help-general] [--formats]
10 [-s_srs srs_def] [-t_srs srs_def] [-ct string] [-to "NAME=VALUE"]* [-novshiftgrid]
11 [-order n | -tps | -rpc | -geoloc] [-et err_threshold]
12 [-refine_gcps tolerance [minimum_gcps]]
13 [-te xmin ymin xmax ymax] [-te_srs srs_def]
14 [-tr xres yres] [-tap] [-ts width height]
15 [-ovr level|AUTO|AUTO-n|NONE] [-wo "NAME=VALUE"] [-ot Byte/Int16/...] [-wt Byte/Int16]
16 [-srcnodata "value [value...]"] [-dstnodata "value [value...]"]
17 [-srcalpha|-nosrcalpha] [-dstalpha]
18 [-r resampling_method] [-wm memory_in_mb] [-multi] [-q]
19 [-cutline datasource] [-cl layer] [-cwhere expression]
20 [-csql statement] [-cblend dist_in_pixels] [-crop_to_cutline]
21 [-if format]* [-of format] [-co "NAME=VALUE"]* [-overwrite]
22 [-nomd] [-cvmd meta_conflict_value] [-setci] [-oo NAME=VALUE]*
23 [-doo NAME=VALUE]*
24 srcfile* dstfile
25
27 The gdalwarp utility is an image mosaicing, reprojection and warping
28 utility. The program can reproject to any supported projection, and can
29 also apply GCPs stored with the image if the image is "raw" with con‐
30 trol information.
31
32 -s_srs <srs def>
33 Set source spatial reference.
34
35 The coordinate systems that can be passed are anything supported
36 by the OGRSpatialReference.SetFromUserInput() call, which in‐
37 cludes EPSG PCS and GCSes (i.e. EPSG:4296), PROJ.4 declarations
38 (as above), or the name of a .prj file containing well known
39 text. Starting with GDAL 2.2, if the SRS has an explicit verti‐
40 cal datum that points to a PROJ.4 geoidgrids, and the input
41 dataset is a single band dataset, a vertical correction will be
42 applied to the values of the dataset.
43
44 -t_srs <srs_def>
45 Set target spatial reference.
46
47 The coordinate systems that can be passed are anything supported
48 by the OGRSpatialReference.SetFromUserInput() call, which in‐
49 cludes EPSG PCS and GCSes (i.e. EPSG:4296), PROJ.4 declarations
50 (as above), or the name of a .prj file containing well known
51 text. Starting with GDAL 2.2, if the SRS has an explicit verti‐
52 cal datum that points to a PROJ.4 geoidgrids, and the input
53 dataset is a single band dataset, a vertical correction will be
54 applied to the values of the dataset.
55
56 -ct <string>
57 A PROJ string (single step operation or multiple step string
58 starting with +proj=pipeline), a WKT2 string describing a Coor‐
59 dinateOperation, or a urn:ogc:def:coordinateOperation:EPSG::XXXX
60 URN overriding the default transformation from the source to the
61 target CRS. It must take into account the axis order of the
62 source and target CRS.
63
64 New in version 3.0.
65
66
67 -to <NAME=VALUE>
68 Set a transformer option suitable to pass to GDALCreateGenImg‐
69 ProjTransformer2().
70
71 -novshiftgrid
72 Disable the use of vertical datum shift grids when one of the
73 source or target SRS has an explicit vertical datum, and the in‐
74 put dataset is a single band dataset.
75
76 New in version 2.2.
77
78
79 -order <n>
80 order of polynomial used for warping (1 to 3). The default is to
81 select a polynomial order based on the number of GCPs.
82
83 -tps Force use of thin plate spline transformer based on available
84 GCPs.
85
86 -rpc Force use of RPCs.
87
88 -geoloc
89 Force use of Geolocation Arrays.
90
91 -et <err_threshold>
92 Error threshold for transformation approximation (in pixel units
93 - defaults to 0.125, unless, starting with GDAL 2.1, the RPC_DEM
94 warping option is specified, in which case, an exact trans‐
95 former, i.e. err_threshold=0, will be used).
96
97 -refine_gcps <tolerance minimum_gcps>
98 Refines the GCPs by automatically eliminating outliers. Out‐
99 liers will be eliminated until minimum_gcps are left or when no
100 outliers can be detected. The tolerance is passed to adjust
101 when a GCP will be eliminated. Not that GCP refinement only
102 works with polynomial interpolation. The tolerance is in pixel
103 units if no projection is available, otherwise it is in SRS
104 units. If minimum_gcps is not provided, the minimum GCPs ac‐
105 cording to the polynomial model is used.
106
107 -te <xmin ymin xmax ymax>
108 Set georeferenced extents of output file to be created (in tar‐
109 get SRS by default, or in the SRS specified with -te_srs)
110
111 -te_srs <srs_def>
112 Specifies the SRS in which to interpret the coordinates given
113 with -te. The <srs_def> may be any of the usual GDAL/OGR forms,
114 complete WKT, PROJ.4, EPSG:n or a file containing the WKT. This
115 must not be confused with -t_srs which is the target SRS of the
116 output dataset. -te_srs is a convenience e.g. when knowing the
117 output coordinates in a geodetic long/lat SRS, but still wanting
118 a result in a projected coordinate system.
119
120 -tr <xres> <yres>
121 Set output file resolution (in target georeferenced units)
122
123 -tap (target aligned pixels) align the coordinates of the extent of
124 the output file to the values of the -tr, such that the aligned
125 extent includes the minimum extent.
126
127 -ts <width> <height>
128 Set output file size in pixels and lines. If width or height is
129 set to 0, the other dimension will be guessed from the computed
130 resolution. Note that -ts cannot be used with -tr
131
132 -ovr <level|AUTO|AUTO-n|NONE>
133 To specify which overview level of source files must be used.
134 The default choice, AUTO, will select the overview level whose
135 resolution is the closest to the target resolution. Specify an
136 integer value (0-based, i.e. 0=1st overview level) to select a
137 particular level. Specify AUTO-n where n is an integer greater
138 or equal to 1, to select an overview level below the AUTO one.
139 Or specify NONE to force the base resolution to be used (can be
140 useful if overviews have been generated with a low quality re‐
141 sampling method, and the warping is done using a higher quality
142 resampling method).
143
144 -wo `"NAME=VALUE"`
145 Set a warp option. The GDALWarpOptions::papszWarpOptions docs
146 show all options. Multiple -wo options may be listed.
147
148 -ot <type>
149 Force the output image bands to have a specific data type sup‐
150 ported by the driver, which may be one of the following: Byte,
151 UInt16, Int16, UInt32, Int32, Float32, Float64, CInt16, CInt32,
152 CFloat32 or CFloat64.
153
154 -wt <type>
155 Working pixel data type. The data type of pixels in the source
156 image and destination image buffers.
157
158 -r <resampling_method>
159 Resampling method to use. Available methods are:
160
161 near: nearest neighbour resampling (default, fastest algorithm,
162 worst interpolation quality).
163
164 bilinear: bilinear resampling.
165
166 cubic: cubic resampling.
167
168 cubicspline: cubic spline resampling.
169
170 lanczos: Lanczos windowed sinc resampling.
171
172 average: average resampling, computes the weighted average of
173 all non-NODATA contributing pixels.
174
175 mode: mode resampling, selects the value which appears most of‐
176 ten of all the sampled points.
177
178 max: maximum resampling, selects the maximum value from all
179 non-NODATA contributing pixels.
180
181 min: minimum resampling, selects the minimum value from all
182 non-NODATA contributing pixels.
183
184 med: median resampling, selects the median value of all non-NO‐
185 DATA contributing pixels.
186
187 q1: first quartile resampling, selects the first quartile value
188 of all non-NODATA contributing pixels.
189
190 q3: third quartile resampling, selects the third quartile value
191 of all non-NODATA contributing pixels.
192
193 sum: compute the weighted sum of all non-NODATA contributing
194 pixels (since GDAL 3.1)
195
196 -srcnodata <value [value...]>
197 Set nodata masking values for input bands (different values can
198 be supplied for each band). If more than one value is supplied
199 all values should be quoted to keep them together as a single
200 operating system argument. Masked values will not be used in
201 interpolation. Use a value of None to ignore intrinsic nodata
202 settings on the source dataset.
203
204 -dstnodata <value [value...]>
205 Set nodata values for output bands (different values can be sup‐
206 plied for each band). If more than one value is supplied all
207 values should be quoted to keep them together as a single oper‐
208 ating system argument. New files will be initialized to this
209 value and if possible the nodata value will be recorded in the
210 output file. Use a value of None to ensure that nodata is not
211 defined. If this argument is not used then nodata values will
212 be copied from the source dataset.
213
214 -srcalpha
215 Force the last band of a source image to be considered as a
216 source alpha band.
217
218 -nosrcalpha
219 Prevent the alpha band of a source image to be considered as
220 such (it will be warped as a regular band)
221
222 New in version 2.2.
223
224
225 -dstalpha
226 Create an output alpha band to identify nodata (unset/transpar‐
227 ent) pixels.
228
229 -wm <memory_in_mb>
230 Set the amount of memory that the warp API is allowed to use for
231 caching. The value is interpreted as being in megabytes if the
232 value is less than 10000. For values >=10000, this is inter‐
233 preted as bytes.
234
235 -multi Use multithreaded warping implementation. Two threads will be
236 used to process chunks of image and perform input/output opera‐
237 tion simultaneously. Note that computation is not multithreaded
238 itself. To do that, you can use the -wo NUM_THREADS=val/ALL_CPUS
239 option, which can be combined with -multi
240
241 -q Be quiet.
242
243 -if <format>
244 Format/driver name to be attempted to open the input file(s). It
245 is generally not necessary to specify it, but it can be used to
246 skip automatic driver detection, when it fails to select the ap‐
247 propriate driver. This option can be repeated several times to
248 specify several candidate drivers.
249
250 New in version 3.2.
251
252
253 -of <format>
254 Select the output format. Starting with GDAL 2.3, if not speci‐
255 fied, the format is guessed from the extension (previously was
256 GTiff). Use the short format name.
257
258 -co <NAME=VALUE>
259 Many formats have one or more optional creation options that can
260 be used to control particulars about the file created. For in‐
261 stance, the GeoTIFF driver supports creation options to control
262 compression, and whether the file should be tiled.
263
264 The creation options available vary by format driver, and some
265 simple formats have no creation options at all. A list of op‐
266 tions supported for a format can be listed with the --formats
267 command line option but the documentation for the format is the
268 definitive source of information on driver creation options.
269 See raster_drivers format specific documentation for legal cre‐
270 ation options for each format.
271
272 -cutline <datasource>
273 Enable use of a blend cutline from the name OGR support data‐
274 source.
275
276 -cl <layername>
277 Select the named layer from the cutline datasource.
278
279 -cwhere <expression>
280 Restrict desired cutline features based on attribute query.
281
282 -csql <query>
283 Select cutline features using an SQL query instead of from a
284 layer with -cl.
285
286 -cblend <distance>
287 Set a blend distance to use to blend over cutlines (in pixels).
288
289 -crop_to_cutline
290 Crop the extent of the target dataset to the extent of the cut‐
291 line.
292
293 -overwrite
294 Overwrite the target dataset if it already exists.
295
296 -nomd Do not copy metadata. Without this option, dataset and band
297 metadata (as well as some band information) will be copied from
298 the first source dataset. Items that differ between source
299 datasets will be set to * (see -cvmd option).
300
301 -cvmd <meta_conflict_value>
302 Value to set metadata items that conflict between source
303 datasets (default is "*"). Use "" to remove conflicting items.
304
305 -setci Set the color interpretation of the bands of the target dataset
306 from the source dataset.
307
308 -oo <NAME=VALUE>
309 Dataset open option (format specific)
310
311 -doo <NAME=VALUE>
312 Output dataset open option (format specific)
313
314 New in version 2.1.
315
316
317 <srcfile>
318 The source file name(s).
319
320 <dstfile>
321 The destination file name.
322
323 Mosaicing into an existing output file is supported if the output file
324 already exists. The spatial extent of the existing file will not be
325 modified to accommodate new data, so you may have to remove it in that
326 case, or use the -overwrite option.
327
328 Polygon cutlines may be used as a mask to restrict the area of the des‐
329 tination file that may be updated, including blending. If the OGR
330 layer containing the cutline features has no explicit SRS, the cutline
331 features must be in the SRS of the destination file. When writing to a
332 not yet existing target dataset, its extent will be the one of the
333 original raster unless -te or -crop_to_cutline are specified.
334
335 When doing vertical shift adjustments, the transformer option -to ER‐
336 ROR_ON_MISSING_VERT_SHIFT=YES can be used to error out as soon as a
337 vertical shift value is missing (instead of 0 being used).
338
339 Starting with GDAL 3.1, it is possible to use as output format a driver
340 that only supports the CreateCopy operation. This may internally imply
341 creation of a temporary file.
342
344 • Basic transformation:
345
346 gdalwarp -t_srs EPSG:4326 input.tif output.tif
347
348 • For instance, an eight bit spot scene stored in GeoTIFF with control
349 points mapping the corners to lat/long could be warped to a UTM pro‐
350 jection with a command like this:
351
352 gdalwarp -t_srs '+proj=utm +zone=11 +datum=WGS84' -overwrite raw_spot.tif utm11.tif
353
354 • For instance, the second channel of an ASTER image stored in HDF with
355 control points mapping the corners to lat/long could be warped to a
356 UTM projection with a command like this:
357 New in version 2.2.
358
359
360 gdalwarp -overwrite HDF4_SDS:ASTER_L1B:"pg-PR1B0000-2002031402_100_001":2 pg-PR1B0000-2002031402_100_001_2.tif
361
362 • To apply a cutline on a un-georeferenced image and clip from pixel
363 (220,60) to pixel (1160,690):
364
365 gdalwarp -overwrite -to SRC_METHOD=NO_GEOTRANSFORM -to DST_METHOD=NO_GEOTRANSFORM -te 220 60 1160 690 -cutline cutline.csv in.png out.tif
366
367 where cutline.csv content is like:
368
369 id,WKT
370 1,"POLYGON((....))"
371
372 • To transform a DEM from geoid elevations (using EGM96) to WGS84 el‐
373 lipsoidal heights:
374 New in version 2.2.
375
376
377 gdalwarp -overwrite in_dem.tif out_dem.tif -s_srs EPSG:4326+5773 -t_srs EPSG:4979
378
380 Wiki page discussing options and behaviours of gdalwarp
381
383 Frank Warmerdam <warmerdam@pobox.com>, Silke Reimer <silke@inteva‐
384 tion.de>
385
387 1998-2021
388
389
390
391
392 Mar 24, 2021 GDALWARP(1)