Show this help message and exit
-ot <type>
Force the output image bands to have a specific data type supported by the
driver, which may be one of the following: Byte
, Int8
, UInt16
,
Int16
, UInt32
, Int32
, UInt64
, Int64
, Float32
, Float64
, CInt16
,
CInt32
, CFloat32
or CFloat64
.
-if <format>
Format/driver name to be attempted to open the input file(s). It is generally
not necessary to specify it, but it can be used to skip automatic driver
detection, when it fails to select the appropriate driver.
This option can be repeated several times to specify several candidate drivers.
New in version 3.2.
-of <format>
Select the output format. Starting with GDAL 2.3, if not specified, the
format is guessed from the extension (previously was GTiff). Use the short
format name.
-b <band>
Select an input band band for output. Bands are numbered from 1.
Multiple -b
switches may be used to select a set of input bands
to write to the output file, or to reorder bands. band can also be set
to "mask,1" (or just "mask") to mean the mask band of the first band of the
input dataset.
-mask <band>
Select an input band band to create output dataset mask band. Bands are
numbered from 1. band can be set to "none" to avoid copying the global
mask of the input dataset if it exists. Otherwise it is copied by default
("auto"), unless the mask is an alpha channel, or if it is explicitly used
to be a regular band of the output dataset ("-b mask"). band can also
be set to "mask,1" (or just "mask") to mean the mask band of the 1st band
of the input dataset.
-expand gray|rgb|rgba
To expose a dataset with 1 band with a color table as a dataset with
3 (RGB) or 4 (RGBA) bands. Useful for output drivers such as JPEG,
JPEG2000, MrSID, ECW that don't support color indexed datasets. The 'gray'
value enables to expand a dataset with a color table that only contains
gray levels to a gray indexed dataset.
-outsize <xsize>[%]|0 <ysize>[%]|0
Set the size of the output file. Outsize is in pixels and lines unless '%'
is attached in which case it is as a fraction of the input image size.
If one of the 2 values is set to 0, its value will be determined from the
other one, while maintaining the aspect ratio of the source dataset.
-tr <xres> <yres>
set target resolution. The values must be expressed in georeferenced units.
Both must be positive values. This is mutually exclusive with
-outsize
, -a_ullr
, and -a_gt
.
New in version 3.6.
To specify which overview level of source file must be used. The default choice,
AUTO, will select the overview level whose resolution is the closest to the
target resolution. Specify an integer value (0-based, i.e. 0=1st overview level)
to select a particular level. Specify AUTO-n where n is an integer greater or
equal to 1, to select an overview level below the AUTO one. Or specify NONE to
force the base resolution to be used (can be useful if overviews have been
generated with a low quality resampling method, and a higher quality resampling method
is specified with -r
.
When -ovr
is specified to an integer value,
and none of -outsize
and -tr
is specified, the size of
the overview will be used as the output size.
When -ovr
is specified, values of -srcwin
, when specified,
should be expressed as pixel offset and size of the full resolution source dataset.
Similarly when using -outsize
with percentage values, they refer to the size
of the full resolution source dataset.
-r {nearest|bilinear|cubic|cubicspline|lanczos|average|rms|mode}
Select a resampling algorithm.
nearest
(default) applies a nearest neighbour (simple sampling) resampler
average
computes the average of all non-NODATA contributing pixels. Starting with GDAL 3.1, this is a weighted average taking into account properly the weight of source pixels not contributing fully to the target pixel.
rms
computes the root mean squared / quadratic mean of all non-NODATA contributing pixels (GDAL >= 3.3)
bilinear
applies a bilinear convolution kernel.
cubic
applies a cubic convolution kernel.
cubicspline
applies a B-Spline convolution kernel.
lanczos
applies a Lanczos windowed sinc convolution kernel.
mode
selects the value which appears most often of all the sampled points.
-scale [<src_min> <src_max> [<dst_min> <dst_max>]]
Rescale the input pixels values from the range src_min to src_max
to the range dst_min to dst_max.
If omitted the output range is 0 to 255.
If omitted the input range is automatically computed from the
source dataset, in its whole (not just the window of interest potentially
specified with -srcwin
or -projwin
). This may be a
slow operation on a large source dataset, and if using it multiple times
for several gdal_translate invocation, it might be beneficial to call
gdalinfo -stats {source_dataset}
priorly to precompute statistics, for
formats that support serializing statistics computations (GeoTIFF, VRT...)
Note that the values specified after -scale
are only used to compute a scale and
offset to apply to the input raster values. In particular, src_min
and
src_max
are not used to clip input values.
-scale
can be repeated several times (if specified only once,
it also applies to all bands of the output dataset), so as to specify per
band parameters. It is also possible to use the "-scale_bn" syntax where bn
is a band number (e.g. "-scale_2" for the 2nd band of the output dataset)
to specify the parameters of one or several specific bands.
-exponent <exp_val>
To apply non-linear scaling with a power function. exp_val is the exponent
of the power function (must be positive). This option must be used with the
-scale option. If specified only once, -exponent applies to all bands of
the output image. It can be repeated several times so as to specify per
band parameters. It is also possible to use the "-exponent_bn" syntax where
bn is a band number (e.g. "-exponent_2" for the 2nd band of the output
dataset) to specify the parameters of one or several specific bands.
-unscale
Apply the scale/offset metadata for the bands to convert scaled values to
unscaled values. It is also often necessary to reset the output datatype
with the -ot
switch.
The unscaled value is computed from the scaled raw value with the following
formula:
\[{unscaled\_value} = {scaled\_value} * {scale} + {offset}\]