gdaltranslate
gdal_translate is a command-line utility that is part of the Geospatial Data Abstraction Library (GDAL). It is used to convert raster data between formats and to apply a range of basic transformations during the conversion, such as changing size, data type, or georeferencing, as well as clipping and adjusting pixel values. It is commonly used to prepare raster data for different software ecosystems, optimize storage, or extract subsets of larger datasets.
The typical invocation is: gdal_translate [options] srcfile dstfile. Key options include:
- -of format to specify the output driver or file format (for example, GTiff, JPEG, IMG).
- -ot datatype to set the output pixel type (for example, Byte, UInt16, Float32).
- -a_srs srs to assign a spatial reference system to the output.
- -a_nodata value to designate a nodata value in the output.
- -a_ullr ulx uly lrx lry to assign georeferenced coordinates to the output.
- -srcwin xoff yoff xsize ysize to subset by pixel coordinates.
- -projwin ulx uly lrx lry to subset by georeferenced coordinates.
- -outsize xsize ysize to resample to a specific output dimension.
- -scale in_min in_max out_min out_max to map input pixel values to a new range.
- -r resampling_method to control resampling when changing resolution (for example, near, bilinear, cubic).
- -co "NAME=VALUE" to pass creation options to the output driver.
- -b band to select specific bands to include in the output.
Converting a GeoTIFF to JPEG: gdal_translate -of JPEG input.tif output.jpg.
Clipping to a region: gdal_translate -projwin ulx uly lrx lry -a_srs EPSG:4326 input.tif clipped.tif.
Resampling to a new size: gdal_translate -outsize 1024 768 input.tif resized.tif.
Setting nodata: gdal_translate -a_nodata -9999 input.tif nodata.tif.
gdal_translate emphasizes format interchange and lightweight processing, and it forms a common first step in GDAL-based
---