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,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,average,mode}
97              Select a resampling algorithm.
98
99       -scale [src_min src_max [dst_min dst_max]]
100              Rescale  the  input  pixels  values  from  the  range src_min to
101              src_max to the range dst_min to dst_max.  If omitted the  output
102              range  is 0 to 255.  If omitted the input range is automatically
103              computed from the source data. -scale can  be  repeated  several
104              times  (if  specified only once, it also applies to all bands of
105              the output dataset), so as to specify per band parameters. It is
106              also  possible  to use the "-scale_bn" syntax where bn is a band
107              number (e.g. "-scale_2" for the 2nd band of the output  dataset)
108              to specify the parameters of one or several specific bands.
109
110       -exponent <exp_val>
111              To  apply  non-linear  scaling with a power function. exp_val is
112              the exponent of the power function (must be positive). This  op‐
113              tion  must  be  used  with  the -scale option. If specified only
114              once, -exponent applies to all bands of the output image. It can
115              be  repeated several times so as to specify per band parameters.
116              It is also possible to use the "-exponent_bn" syntax where bn is
117              a band number (e.g. "-exponent_2" for the 2nd band of the output
118              dataset) to specify the parameters of one  or  several  specific
119              bands.
120
121       -unscale
122              Apply  the scale/offset metadata for the bands to convert scaled
123              values to unscaled values.  It is also often necessary to  reset
124              the output datatype with the -ot switch.
125
126       -srcwin <xoff> <yoff> <xsize> <ysize>
127              Selects  a  subwindow from the source image for copying based on
128              pixel/line location.
129
130       -projwin <ulx> <uly> <lrx> <lry>
131              Selects a subwindow from the  source  image  for  copying  (like
132              -srcwin) but with the corners given in georeferenced coordinates
133              (by default expressed in the SRS of the dataset. Can be  changed
134              with -projwin_srs).
135
136              NOTE:
137                 In  GDAL 2.1.0 and 2.1.1, using -projwin with coordinates not
138                 aligned with pixels will result in a  sub-pixel  shift.  This
139                 has   been   corrected  in  later  versions.  When  selecting
140                 non-nearest neighbour resampling, starting with  GDAL  2.1.0,
141                 sub-pixel accuracy is however used to get better results.
142
143       -projwin_srs <srs_def>
144              Specifies  the  SRS  in which to interpret the coordinates given
145              with -projwin. The <srs_def> may be any of  the  usual  GDAL/OGR
146              forms,  complete  WKT,  PROJ.4,  EPSG:n or a file containing the
147              WKT.
148
149              WARNING:
150                 This does not cause reprojection of the dataset to the speci‐
151                 fied SRS.
152
153       -epo   (Error when Partially Outside) If this option is set, -srcwin or
154              -projwin values that falls partially outside the  source  raster
155              extent  will  be considered as an error. The default behavior is
156              to accept such requests, when they were considered as  an  error
157              before.
158
159       -eco   (Error  when  Completely  Outside) Same as -epo, except that the
160              criterion for erroring out is when the request falls  completely
161              outside the source raster extent.
162
163       -a_srs <srs_def>
164              Override  the  projection for the output file.  The<srs_def> may
165              be any of the usual GDAL/OGR forms, complete WKT, PROJ.4, EPSG:n
166              or a file containing the WKT. No reprojection is done.
167
168       -a_scale <value>
169              Set band scaling value(no modification of pixel values is done)
170
171              New in version 2.3.
172
173
174       -a_offset<value>
175              Set band offset value (no modification of pixel values is done)
176
177              New in version 2.3.
178
179
180       -a_ullr <ulx> <uly> <lrx> <lry>
181              Assign/override  the  georeferenced  bounds  of the output file.
182              This assigns georeferenced bounds to the output  file,  ignoring
183              what  would have been derived from the source file. So this does
184              not cause reprojection to the specified SRS.
185
186       -a_nodata <value>
187              Assign a specified nodata value to output bands. It can  be  set
188              to  <i>none</i>  to  avoid  setting a nodata value to the output
189              file if one exists for the source file. Note that, if the  input
190              dataset  has  a  nodata  value, this does not cause pixel values
191              that are equal to that nodata value to be changed to  the  value
192              specified with this option.
193
194       -colorinterp_X <red|green|blue|alpha|gray|undefined>
195              Override  the color interpretation of band X (where X is a valid
196              band number, starting at 1)
197
198              New in version 2.3.
199
200
201       -colorinterp   <red|green|blue|alpha|gray|undefined[,red|green|blue|al‐
202       pha|gray|undefined]*>
203              Override  the  color  interpretation of all specified bands. For
204              example -colorinterp red,green,blue,alpha for a  4  band  output
205              dataset.
206
207              New in version 2.3.
208
209
210       -mo META-TAG=VALUE
211              Passes  a metadata key and value to set on the output dataset if
212              possible.
213
214       -co <NAME=VALUE>
215              Many formats have one or more optional creation options that can
216              be  used  to control particulars about the file created. For in‐
217              stance, the GeoTIFF driver supports creation options to  control
218              compression, and whether the file should be tiled.
219
220              The  creation  options available vary by format driver, and some
221              simple formats have no creation options at all. A  list  of  op‐
222              tions  supported  for  a format can be listed with the --formats
223              command line option but the documentation for the format is  the
224              definitive  source  of  information  on driver creation options.
225              See raster_drivers format specific documentation for legal  cre‐
226              ation options for each format.
227
228       -nogcp Do  not  copy  the  GCPs  in  the  source  dataset to the output
229              dataset.
230
231       -gcp <pixel> <line> <easting> <northing> <elevation>
232              Add the indicated ground control point to  the  output  dataset.
233              This  option  may be provided multiple times to provide a set of
234              GCPs.
235
236       -q     Suppress progress monitor and other non-error output.
237
238       -sds   Copy all subdatasets of this file to  individual  output  files.
239              Use with formats like HDF that have subdatasets.
240
241       -stats Force (re)computation of statistics.
242
243       -norat Do not copy source RAT into destination dataset.
244
245       -noxmp Do not copy the XMP metadata in the source dataset to the output
246              dataset when driver is able to copy it.
247
248              New in version 3.2.
249
250
251       -oo NAME=VALUE
252              Dataset open option (format specific)
253
254       <src_dataset>
255              The source dataset name. It can be either file name, URL of data
256              source or subdataset name for multi-dataset files.
257
258       <dst_dataset>
259              The destination file name.
260

C API

262       This utility is also callable from C with GDALTranslate().
263
264       New in version 2.1.
265
266

EXAMPLES

268          gdal_translate -of GTiff -co "TILED=YES" utm.tif utm_tiled.tif
269
270       To create a JPEG-compressed TIFF with internal mask from a RGBA dataset
271
272          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
273
274       To create a RGBA dataset from a RGB dataset with a mask
275
276          gdal_translate withmask.tif rgba.tif -b 1 -b 2 -b 3 -b mask
277

AUTHOR

279       Frank  Warmerdam  <warmerdam@pobox.com>,  Silke  Reimer  <silke@inteva‐
280       tion.de>
281
283       1998-2021
284
285
286
287
288                                 Mar 24, 2021                GDAL_TRANSLATE(1)
Impressum