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              [-of format] [-b band]* [-mask band] [-expand {gray|rgb|rgba}]
13              [-outsize xsize[%]|0 ysize[%]|0] [-tr xres yres]
14              [-r {nearest,bilinear,cubic,cubicspline,lanczos,average,mode}]
15              [-unscale] [-scale[_bn] [src_min src_max [dst_min dst_max]]]* [-exponent[_bn] exp_val]*
16              [-srcwin xoff yoff xsize ysize] [-epo] [-eco]
17              [-projwin ulx uly lrx lry] [-projwin_srs srs_def]
18              [-a_srs srs_def] [-a_ullr ulx uly lrx lry] [-a_nodata value]
19              [-a_scale value] [-a_offset value]
20              [-nogcp] [-gcp pixel line easting northing [elevation]]*
21              |-colorinterp{_bn} {red|green|blue|alpha|gray|undefined}]
22              |-colorinterp {red|green|blue|alpha|gray|undefined},...]
23              [-mo "META-TAG=VALUE"]* [-q] [-sds]
24              [-co "NAME=VALUE"]* [-stats] [-norat]
25              [-oo NAME=VALUE]*
26              src_dataset dst_dataset
27

DESCRIPTION

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

C API

243       This utility is also callable from C with GDALTranslate().
244
245       New in version 2.1.
246
247

EXAMPLES

249          gdal_translate -of GTiff -co "TILED=YES" utm.tif utm_tiled.tif
250
251       To create a JPEG-compressed TIFF with internal mask from a RGBA dataset
252
253          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
254
255       To create a RGBA dataset from a RGB dataset with a mask
256
257          gdal_translate withmask.tif rgba.tif -b 1 -b 2 -b 3 -b mask
258

AUTHOR

260       Frank  Warmerdam  <warmerdam@pobox.com>,  Silke  Reimer  <silke@inteva‐
261       tion.de>
262
264       1998-2021
265
266
267
268
269                                 Jan 05, 2021                GDAL_TRANSLATE(1)
Impressum