Language/Format: Numpy, PIL, Python
Application type(s): Data Conversion, Visualization
Related project(s):


This pure-python application creates a 256 colors image of a 2D HDF4 SDS. It supports different colormaps, min/max thresholding, scaling, fill value filtering…

Many output image formats are also supported.

Classes in this package can also be called as python libraries in your own programs :

  •  : processor for building an image from a HDF dataset
  • : processor for building an image from a numpy array


  • Only 2D datasets are currently supported


Usage: hdf2img [options]   

  <infile>             HDF4 input file
  <sds>                Name of the SDS to be drawn
 -h, --help            show this help message and exit
 -o OUTFILE, --output=OUTFILE
                       The output file name. The output image file format
                       will be based on the file extension. If not given,
                       <input-dir>/<input-file-without-   extension>_<sds>.png
                       will be used
 -c COLORMAP, --colormap=COLORMAP
                       The colormap (ocean,bw_linear,red_temp,blue,blue_red,r
                       ainbow,rainbow_white,lidar_nasa) to use or the
                       colormap file name
 -S SCALE, --scale=SCALE
                       The type of scale to use&nbsp;:  linear(default), log
 -m THRESHOLD_MIN, --threshold_min=THRESHOLD_MIN
                       The values smaller than threshold_min will be clipped
                       to it
 -n THRESHOLD_MAX, --threshold_max=THRESHOLD_MAX
                       The values greater than threshold_min will be clipped
                       to it
 -w INVALID, --invalid=INVALID
                       The invalid fill value (optional)
 -u INVALID_IDX, --invalid_idx=INVALID_IDX
                       The invalid fill value colormap index (optional)
 -v, --verbose         Print out processing informations
 -d, --is_palette_index
                       Palette values are a index.
 -x, --overwrite       Overwrite the output file if already existent


Source can be downloaded here :


Package can be browsed here :



Installation process is detailed in the README and INSTALL files at the root of the package


Copyright (C) 2010 Icare – ICARE web site

Nicolas PASCAL,

This program is a free software; you can redistribute it and/or modify it under the terms of the CeCILL Public License as published by (License version 2 or later).

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL Public License for more details.

You should have received a copy of the CeCILL Public License along with this program; if not, please contact

For any questions or concerns regarding this program, or general information about the ICARE Project, please email to

Author(s): Nicolas Pascal (ICARE)