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