1GDAL_TRANSLATE(1)                    GDAL                    GDAL_TRANSLATE(1)
2
3
4

NAME

6       gdal_translate - Converts raster data between different formats.
7

SYNOPSIS

9          gdal_translate [--help-general]
10              [-ot {Byte/Int16/UInt16/UInt32/Int32/Float32/Float64/
11                      CInt16/CInt32/CFloat32/CFloat64}] [-strict]
12              [-if format]* [-of format]
13              [-b band]* [-mask band] [-expand {gray|rgb|rgba}]
14              [-outsize xsize[%]|0 ysize[%]|0] [-tr xres yres]
15              [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,rms,mode}]
16              [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]*
17              [-srcwin xoff yoff xsize ysize] [-epo] [-eco]
18              [-projwin ulx uly lrx lry] [-projwin_srs srs_def]
19              [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value]
20              [-a_scale value] [-a_offset value]
21              [-nogcp] [-gcp pixel line easting northing [elevation]]*
22              |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}]
23              |-colorinterp {red|green|blue|alpha|gray|undefined},...]
24              [-mo "META-TAG=VALUE"]* [-q] [-sds]
25              [-co "NAME=VALUE"]* [-stats] [-norat] [-noxmp]
26              [-oo NAME=VALUE]*
27              src_dataset dst_dataset
28

DESCRIPTION

30       The  gdal_translate  utility can be used to convert raster data between
31       different formats, potentially performing some operations like  subset‐
32       tings, resampling, and rescaling pixels in the process.
33
34       -ot <type>
35              Force  the  output image bands to have a specific data type sup‐
36              ported by the driver, which may be one of the  following:  Byte,
37              UInt16,  Int16, UInt32, Int32, Float32, Float64, CInt16, CInt32,
38              CFloat32 or CFloat64.
39
40       -strict
41              Don't be forgiving of mismatches and lost data when  translating
42              to the output format.
43
44       -if <format>
45              Format/driver name to be attempted to open the input file(s). It
46              is generally not necessary to specify it, but it can be used  to
47              skip automatic driver detection, when it fails to select the ap‐
48              propriate driver.  This option can be repeated several times  to
49              specify several candidate drivers.
50
51              New in version 3.2.
52
53
54       -of <format>
55              Select  the output format. Starting with GDAL 2.3, if not speci‐
56              fied, the format is guessed from the extension  (previously  was
57              GTiff). Use the short format name.
58
59       -b <band>
60              Select an input band band for output. Bands are numbered from 1.
61              Multiple -b switches may be used to select a set of input  bands
62              to  write to the output file, or to reorder bands. band can also
63              be set to "mask,1" (or just "mask") to mean the mask band of the
64              first band of the input dataset.
65
66       -mask <band>
67              Select  an  input  band band to create output dataset mask band.
68              Bands are numbered from 1. band can be set to  "none"  to  avoid
69              copying  the global mask of the input dataset if it exists. Oth‐
70              erwise it is copied by default ("auto"), unless the mask  is  an
71              alpha  channel, or if it is explicitly used to be a regular band
72              of the output dataset ("-b mask").  band  can  also  be  set  to
73              "mask,1"  (or just "mask") to mean the mask band of the 1st band
74              of the input dataset.
75
76       -expand gray|rgb|rgba
77              To expose a dataset with 1 band with a color table as a  dataset
78              with  3  (RGB) or 4 (RGBA) bands. Useful for output drivers such
79              as JPEG, JPEG2000, MrSID, ECW that don't support  color  indexed
80              datasets.  The  'gray'  value enables to expand a dataset with a
81              color table that only contains gray levels  to  a  gray  indexed
82              dataset.
83
84       -outsize <xsize>[%]|0 <ysize>[%]|0
85              Set the size of the output file.  Outsize is in pixels and lines
86              unless '%' is attached in which case it is as a fraction of  the
87              input image size.  If one of the 2 values is set to 0, its value
88              will be determined from the other one, while maintaining the as‐
89              pect ratio of the source dataset.
90
91       -tr <xres> <yres>
92              set target resolution. The values must be expressed in georefer‐
93              enced units.  Both must be positive values. This is mutually ex‐
94              clusive with -outsize and -a_ullr.
95
96       -r      {nearest     (default),bilinear,cubic,cubicspline,lanczos,aver‐
97       age,rms,mode}
98              Select a resampling algorithm.
99
100              nearest applies a nearest neighbour (simple sampling) resampler
101
102              average computes the average of all non-NODATA contributing pix‐
103              els.  Starting  with GDAL 3.1, this is a weighted average taking
104              into account properly the weight of source pixels not contribut‐
105              ing fully to the target pixel.
106
107              rms  computes  the  root  mean  squared  / quadratic mean of all
108              non-NODATA contributing pixels (GDAL >= 3.3)
109
110              bilinear applies a bilinear convolution kernel.
111
112              cubic applies a cubic convolution kernel.
113
114              cubicspline applies a B-Spline convolution kernel.
115
116              lanczos applies a Lanczos windowed sinc convolution kernel.
117
118              mode selects the value which appears most often of all the  sam‐
119              pled points.
120
121       -scale [src_min src_max [dst_min dst_max]]
122              Rescale  the  input  pixels  values  from  the  range src_min to
123              src_max to the range dst_min to dst_max. If omitted  the  output
124              range  is 0 to 255.  If omitted the input range is automatically
125              computed from the source data. Note that these values  are  only
126              used  to compute a scale and offset to apply to the input raster
127              values. In particular, src_min and src_max are not used to  clip
128              input  values.   -scale can be repeated several times (if speci‐
129              fied only once, it also applies  to  all  bands  of  the  output
130              dataset),  so as to specify per band parameters. It is also pos‐
131              sible to use the "-scale_bn" syntax where bn is  a  band  number
132              (e.g.  "-scale_2"  for  the  2nd  band of the output dataset) to
133              specify the parameters of one or several specific bands.
134
135       -exponent <exp_val>
136              To apply non-linear scaling with a power  function.  exp_val  is
137              the  exponent of the power function (must be positive). This op‐
138              tion must be used with the  -scale  option.  If  specified  only
139              once, -exponent applies to all bands of the output image. It can
140              be repeated several times so as to specify per band  parameters.
141              It is also possible to use the "-exponent_bn" syntax where bn is
142              a band number (e.g. "-exponent_2" for the 2nd band of the output
143              dataset)  to  specify  the parameters of one or several specific
144              bands.
145
146       -unscale
147              Apply the scale/offset metadata for the bands to convert  scaled
148              values  to unscaled values.  It is also often necessary to reset
149              the output datatype with the -ot switch.
150
151       -srcwin <xoff> <yoff> <xsize> <ysize>
152              Selects a subwindow from the source image for copying  based  on
153              pixel/line location.
154
155       -projwin <ulx> <uly> <lrx> <lry>
156              Selects  a  subwindow  from  the  source image for copying (like
157              -srcwin) but with the corners given in georeferenced coordinates
158              (by  default expressed in the SRS of the dataset. Can be changed
159              with -projwin_srs).
160
161              NOTE:
162                 In GDAL 2.1.0 and 2.1.1, using -projwin with coordinates  not
163                 aligned  with  pixels  will result in a sub-pixel shift. This
164                 has  been  corrected  in  later  versions.   When   selecting
165                 non-nearest  neighbour  resampling, starting with GDAL 2.1.0,
166                 sub-pixel accuracy is however used to get better results.
167
168       -projwin_srs <srs_def>
169              Specifies the SRS in which to interpret  the  coordinates  given
170              with  -projwin.  The  <srs_def> may be any of the usual GDAL/OGR
171              forms, complete WKT, PROJ.4, EPSG:n or  a  file  containing  the
172              WKT.
173
174              WARNING:
175                 This does not cause reprojection of the dataset to the speci‐
176                 fied SRS.
177
178       -epo   (Error when Partially Outside) If this option is set, -srcwin or
179              -projwin  values  that falls partially outside the source raster
180              extent will be considered as an error. The default  behavior  is
181              to  accept  such requests, when they were considered as an error
182              before.
183
184       -eco   (Error when Completely Outside) Same as -epo,  except  that  the
185              criterion  for erroring out is when the request falls completely
186              outside the source raster extent.
187
188       -a_srs <srs_def>
189              Override the projection for the output file.
190
191              The coordinate reference systems that can be passed are anything
192              supported  by  the  OGRSpatialReference.SetFromUserInput() call,
193              which includes EPSG Projected, Geographic or Compound CRS  (i.e.
194              EPSG:4296),  a well known text (WKT) CRS definition, PROJ.4 dec‐
195              larations, or the name of a .prj file containing a WKT CRS defi‐
196              nition.
197
198              NOTE:
199                 No reprojection is done.
200
201       -a_scale <value>
202              Set band scaling value (no modification of pixel values is done)
203
204              New in version 2.3.
205
206
207       -a_offset<value>
208              Set band offset value (no modification of pixel values is done)
209
210              New in version 2.3.
211
212
213       -a_ullr <ulx> <uly> <lrx> <lry>
214              Assign/override  the  georeferenced  bounds  of the output file.
215              This assigns georeferenced bounds to the output  file,  ignoring
216              what  would have been derived from the source file. So this does
217              not cause reprojection to the specified SRS.
218
219       -a_nodata <value>
220              Assign a specified nodata value to output bands. It can  be  set
221              to  <i>none</i>  to  avoid  setting a nodata value to the output
222              file if one exists for the source file. Note that, if the  input
223              dataset  has  a  nodata  value, this does not cause pixel values
224              that are equal to that nodata value to be changed to  the  value
225              specified with this option.
226
227       -colorinterp_X <red|green|blue|alpha|gray|undefined>
228              Override  the color interpretation of band X (where X is a valid
229              band number, starting at 1)
230
231              New in version 2.3.
232
233
234       -colorinterp   <red|green|blue|alpha|gray|undefined[,red|green|blue|al‐
235       pha|gray|undefined]*>
236              Override  the  color  interpretation of all specified bands. For
237              example -colorinterp red,green,blue,alpha for a  4  band  output
238              dataset.
239
240              New in version 2.3.
241
242
243       -mo META-TAG=VALUE
244              Passes  a metadata key and value to set on the output dataset if
245              possible.
246
247       -co <NAME=VALUE>
248              Many formats have one or more optional creation options that can
249              be  used  to control particulars about the file created. For in‐
250              stance, the GeoTIFF driver supports creation options to  control
251              compression, and whether the file should be tiled.
252
253              The  creation  options available vary by format driver, and some
254              simple formats have no creation options at all. A  list  of  op‐
255              tions  supported  for  a format can be listed with the --formats
256              command line option but the documentation for the format is  the
257              definitive  source  of  information  on driver creation options.
258              See raster_drivers format specific documentation for legal  cre‐
259              ation options for each format.
260
261       -nogcp Do  not  copy  the  GCPs  in  the  source  dataset to the output
262              dataset.
263
264       -gcp <pixel> <line> <easting> <northing> <elevation>
265              Add the indicated ground control point to  the  output  dataset.
266              This  option  may be provided multiple times to provide a set of
267              GCPs.
268
269       -q     Suppress progress monitor and other non-error output.
270
271       -sds   Copy all subdatasets of this file to  individual  output  files.
272              Use with formats like HDF that have subdatasets.
273
274       -stats Force (re)computation of statistics.
275
276       -norat Do not copy source RAT into destination dataset.
277
278       -noxmp Do not copy the XMP metadata in the source dataset to the output
279              dataset when driver is able to copy it.
280
281              New in version 3.2.
282
283
284       -oo NAME=VALUE
285              Dataset open option (format specific)
286
287       <src_dataset>
288              The source dataset name. It can be either file name, URL of data
289              source or subdataset name for multi-dataset files.
290
291       <dst_dataset>
292              The destination file name.
293

C API

295       This utility is also callable from C with GDALTranslate().
296
297       New in version 2.1.
298
299

EXAMPLES

301          gdal_translate -of GTiff -co "TILED=YES" utm.tif utm_tiled.tif
302
303       To create a JPEG-compressed TIFF with internal mask from a RGBA dataset
304
305          gdal_translate rgba.tif withmask.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES
306
307       To create a RGBA dataset from a RGB dataset with a mask
308
309          gdal_translate withmask.tif rgba.tif -b 1 -b 2 -b 3 -b mask
310

AUTHOR

312       Frank  Warmerdam  <warmerdam@pobox.com>,  Silke  Reimer  <silke@inteva‐
313       tion.de>
314
316       1998-2021
317
318
319
320
321                                 Sep 07, 2021                GDAL_TRANSLATE(1)
Impressum