Monday, 2 July 2012

GDAL usage examples

Some examples of how to use GDAL utility.

Georeference an image:
gdalwarp -te 385300 254100 385400 254200 in.tif out.tif

Export JPEG with RGB channels:
gdal_translate -ot byte -of JPEG -expand rgb in.tif rgb_out.jpg

Force to create TFW for this JPEG file (now it is georeferenced), although previous example also created TFW file by default:
gdal_translate -ot byte -of JPEG -expand rgb -co TFW=YES in.tif jpeg_with_tfw_out.jpg

Correct georeferenced tif by modifying coordinate information:
gdal_translate -a_ullr 385300 254200 385400 254100 -ot byte -of GTiff -co TFW=YES -co NBITS=1 -co COMPRESS=LZW in.tif out.tif

Export regular geotiff (this is a large file):
gdal_translate -ot byte -of GTiff -expand rgb in.tif expanded_geotiff_out.tif

Create LZW copressed geotiff:
gdal_translate -ot byte -of GTiff -co COMPRESS=LZW in.tif compressed_geotiff_out.tif

Export LZW compressed and 1 bit geotiff:
gdal_translate -ot byte -of GTiff -co NBITS=1 -co COMPRESS=LZW in.tif one_bit_geotiff_out.tif

ZLEVEL=9 - set compression level for DEFLATE:
gdal_translate -ot byte -of GTiff -co NBITS=1 -co COMPRESS=DEFLATE -co ZLEVEL=9 in.tif gtiff_with_custom_compress_out.tif

Tiled tiff file:
gdal_translate -ot byte -of GTiff -co NBITS=1 -co COMPRESS=DEFLATE -co ZLEVEL=9 -co TILED=YES in.tif tiled_geotiff_out.tif

1 comment:

Charles Cole said...

Would it be possible to get your example data sets?