Changing geospatial images file format

In the field of Earth Observation, a wide range of file formats exists. Many of them come from software which imposed their home made formats, like Erdas-Imagine HFA files or Envi/IDL file format, while others where created by reasearch groups like HDF made by the HDF group of the University of Illinois or geotiff which is an effort of the open source community in which many Universities or companies are involved.

Unfortunately, it comes that the file format with which you are provided is not necessarily the one you wish to have, whether it is not supported by your software or that it does not match some database requirements.

To make these changes I use gdal_translate which is one of many commands available from FWTools package or from a gdal installation. First install gdal, or better FWTools on your PC, and get some data. We will use the commands from the shell, ms-dos or linux shell (bash for example), the path to your gdal commands (or FWTools commands) must be correctly set. To know if everything works, run the FWTools shell (or open an ms-dos box) or go to your linux prompt and type:
The command should answer a long text like this one:

gdal_translate help and list of formats

gdal_translate help and list of formats

The first section of the text gives you the list of options you can use along with the command line, following the classical convention: parameters between brackets [ ] are optional, braces { } give you a list of choices, parameters without brackets [ ] are mandatory.

Hence, the minimal command you can invoke is
gdal_translate file_in file_out
which will export your input file (in any supported format) into the default output (which is geotiff).
Let’s say you want to transform an Erdas Imagine file named africa.img into a geotiff image named export_africa.tif, you simply write
gdal_translate africa.img export_africa.tif

gdal_translate guess the input format, you do not even need to know it!

Now you can use the -of option to define the export format. Say you want to export to Windisp file format (which name is IDA). Say you want the output image in IDA format to be named africa.ida, you have to write:
gdal_translate -of IDA africa.img africa.ida

Of course, it works only if you input image is in Bytes (8bits) since IDA format only support 8bits.

A short list of format (a reminder) is visible if you type
To see the exhaustive list of formats, type
gdal_translate --formats
The list is rather impressive and tells you if you can read only (ro) or read and write (rw) or even read, write and update existing files (rw+).
gdal_translate --formats | more
to pause when displaying the information (press ENTER to move forward by one line or space to move by one page). You can see that you can read, write and update geotiff or Erdas Imagine formats
GTiff (rw+): GeoTIFF
HFA (rw+): Erdas Imagine Images (.img)
, you can read and write ERMapper Compressed Wavelets images
ECW (rw): ERMapper Compressed Wavelets but only read HDF5 images
HDF5 (ro): Hierarchical Data Format Release 5

You can find more details about formats on the gdal page.

Do not forget that some formats, like windisp IDA, do not support all type of data. For example windisp IDA only support Bytes. When exporting TO this format, you must be sure that your original data can be stored on Bytes, else you need to apply a rescaling of the data.

In next posts, we will see how to use the other options.


0 Responses to “Changing geospatial images file format”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

December 2008
« Nov   Jan »

%d bloggers like this: