Have you ever wondered what is really the file format of an image? Or what are the 4 corners coordinates, or the projection? You can get the answer in a single command line. Say we want to know more about an image name africa.img. Actually the file extension, .img can not be considered as a trustful indication of the real format inside the image, since you can change it as you like. Extensions are only a file naming convention and have nothing to do with the data really written in the file (and the format is much more HOW is written the data).

The command gdalinfo accepts several parameters, to know them simply type:

gdalinfo

and you get a list of optional parameters (which can change in future versions), the only mandatory parameter being the filename (datasetname):

Usage: gdalinfo --help-general -mm -stats -nogcp -nomd -mdd domain* datasetname

To get accurate information on the command line, have a look on <a title="gdalinfo help page" href="http://www.gdal.org/gdalinfo.html" target="_blank">http://www.gdal.org/gdalinfo.html</a> <!nextpage> To guess what is the file format of africa.img, type: gdalinfo africa.img which is the gdal command line that scans for you the file meta-information.

Driver: GTiff/GeoTIFF Size is 963, 818 Coordinate System is: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.2572235629972, AUTHORITY"EPSG","7030"], AUTHORITY"EPSG","6326"], PRIMEM"Greenwich",0, UNIT"degree",0.0174532925199433, AUTHORITY"EPSG","4326"] Origin = (-26.004464290000001,38.004464290000001) Pixel Size = (0.089285714285714,-0.089285714285714) Metadata: AREA_OR_POINT=Area Image Structure Metadata: COMPRESSION=LZW Corner Coordinates: Upper Left ( -26.0044643, 38.0044643) ( 26d 0'16.07"W, 38d 0'16.07"N) Lower Left ( -26.0044643, -35.0312500) ( 26d 0'16.07"W, 35d 1'52.50"S) Upper Right ( 59.9776786, 38.0044643) ( 59d58'39.64"E, 38d 0'16.07"N) Lower Right ( 59.9776786, -35.0312500) ( 59d58'39.64"E, 35d 1'52.50"S) Center ( 16.9866071, 1.4866071) ( 16d59'11.79"E, 1d29'11.79"N) Band 1 Block=963x8 Type=Byte, ColorInterp=Gray Band 2 Block=963x8 Type=Byte, ColorInterp=Undefined

The first line tells you which driver was used to open the image, in this case GeoTiff (changing the filename extension did not have an impact on the capacity to guess the real format). The size of the image is 963 columns by 818 lines. If you have a look at the bottom of the information block, you can see that there are 2 bands. The information Block=963x8 tells you that data are stored by chunks of 8 lines (each line has 963 columns). Most of the lines describe the coordinate system. Here we have a geodetic system (EPSG:4326) on a WGS_1984 spheroid (which parameters are 6378137m at the equator and an inverse flattening factor of about 298.25722). The origin of the image, which corresponds to the corner of the upper left pixel (and not the center of the upper left pixel) is about longitude=-26.004464&deg;, latitude=38.00446429&deg;. The list of pixel coordinates gives you the coordinates of the extreme corners of the image (each time on the corner of the pixel itself, not its center), in decimal and degree, minute, seconds, and the center of the image. The pixel sizes along columns and lines directions are: Pixel Size = (0.089285714285714,-0.089285714285714) The second dimension is negative, since the latitude decreases when the line number increases.

You can see also that the image has internal compression (COMPRESSION=LZW), which is here LZW: it is a loss-less compression.

Now, you can also ask <code>gdalinfo</code> to compute the minimum and maximum on each band, call: gdalinfo -mm africa.img

which returns: Band 1 Block=963x8 Type=Byte, ColorInterp=Gray Computed Min/Max=0.000,226.000 Band 2 Block=963x8 Type=Byte, ColorInterp=Undefined Computed Min/Max=0.000,249.000

You can even get some stats per bands: gdalinfo -stats africa.img and you get:

Band 1 Block=963x8 Type=Byte, ColorInterp=Gray Minimum=0.000, Maximum=226.000, Mean=34.399, StdDev=42.502 Metadata: STATISTICS_MINIMUM=0 STATISTICS_MAXIMUM=226 STATISTICS_MEAN=34.399073799024 STATISTICS_STDDEV=42.501847553726 Band 2 Block=963x8 Type=Byte, ColorInterp=Undefined Minimum=0.000, Maximum=249.000, Mean=59.023, StdDev=77.417 Metadata: STATISTICS_MINIMUM=0 STATISTICS_MAXIMUM=249 STATISTICS_MEAN=59.023071239784 STATISTICS_STDDEV=77.416626675081