GDAL: Define Projection for an Image

This came about when unsidding NAIP. The new image I created (Geotiff) didn’t have a projection defined in the header. A gdalinfo command:

gdalinfo image.tif

Returned:

Driver: GTiff/GeoTIFF
Files: ortho_1-1_1n_s_ga047_2013_1.tif
ortho_1-1_1n_s_ga047_2013_1.tfw
Size is 35113, 28873
Coordinate System is:
Origin = (653694.000000000000000,3875287.000000000000000)
Pixel Size = (1.000000000000000,-1.000000000000000)
Metadata:
TIFFTAG_XRESOLUTION=1
TIFFTAG_YRESOLUTION=1
Image Structure Metadata:
INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left ( 653694.000, 3875287.000)
Lower Left ( 653694.000, 3846414.000)
Upper Right ( 688807.000, 3875287.000)
Lower Right ( 688807.000, 3846414.000)
Center ( 671250.500, 3860850.500)
Band 1 Block=35113×1 Type=Byte, ColorInterp=Red
Band 2 Block=35113×1 Type=Byte, ColorInterp=Green
Band 3 Block=35113×1 Type=Byte, ColorInterp=Blue

To fix this using gdal you only need two things: the EPSG Code of the projection and not being scared of the command line.

  1. Open a terminal or the OSGEO4W shell.
  2. change the directory to your image
  3. Issue the following command:gdal_edit.py -a_srs EPSG:NUMBER image.tif or for an exact example:gdal_edit.py -a_srs EPSG:26916 ortho_1-1_1n_s_ga047_2013_1.tif

Enjoy your newly defined geotiff.