As described in section 1.1, InfoPACK routines can be accessed as Python functions, Python scripts or via the GUI. The latter is simply a front end for the Python scripts. The distinction between the two fundamental ways of calling the routines is as follows:
The scripts have a very similar syntax to the function form, so that switching between them (should you need to do this) is straightforward. Here is an example:
segment.py image_file output_file quality=sensitive
array_out = segment(array_in, quality=sensitive)
InfoPACK import facilities preserve any GIS information in the original file, and the imported NetCDF files can be loaded, processed and saved while continuing to preserve the information. Alternatively, you can ignore it totally if it is not relevant to your application. The way in which this is done is outlined in the next section (Section A.1.3).
Loading and saving of NetCDF files is done by calling the utilities load, save. The load function returns a list with two elements in it; the first is an array containing the image (in Numeric Python format) and the second is a GIS object. For example: from the console
a, gis = load(``file.img'')
returns a list containing a Numeric
array (the actual image data) and a class with the GIS information. Any format recognised
by the GDAL library is valid.
The following code segments the Numeric array ``a'', normalise the original image by the intensity value in each segment and saves the resulting file while preserving the GIS information:
from infopack import *
a, gis = load("file.img")
b = segment(a)
c = a / b
save(c, "result.nc", gis=gis)
Here, a,gis is a list with a containing the image and gis
containing the GIS information. All the InfoPACK .py scripts, and the
GUI buttons, preserve GIS information in this way.
However if you do not care about keeping (or using) the GIS information then you can throw it away:
from infopack import *
a, dummy = load("file.img")
b = segment(a)
c = a / b
save(c, "result.nc")
If you miss out the ", dummy" then "a" will be a list and you
will get all sorts of interesting bugs when you try to use a as an
image (unless you access the numeric array and gis information
via list elements ``a[0]'' and ``a[1]'' respectively).
For convenience, the routine numload only returns the numeric array and gisload only loads the GIS data.
pydoc infopack.routine_name
on the command line.
InfoSAR Ltd