Subsections

File Handling Facilities

ascii2nc


Purpose


Converts an ASCII file into an InfoSAR netcdf file.
This can be useful for generating means and orders files for use in supervised classification. Each line in the ASCII file corresponds to one row of the array. Numbers within a line are separated by white space.


Command Line Script


ascii2nc.py ascii_in image_out


Python Procedure


None provided.



extract


Purpose


Returns a sub-image of given dimensions at the given offsets. The width and height must be specified.


Command Line Script


extract.py image_in image_out width= height= [woffset=] [hoffset=]


Python Procedure


array_out = extract(array_in, width=, height= [,woffset=] [,hoffset=])



Parameters



woffset integer, default 0.


hoffset integer, default 0.


gdal_translate


Purpose


A utility to convert files between various GDAL (Geospatial Data Abstraction Library) formats. The default output format is GeoTIFF. There is limited support for resizing images, selecting subwindows, and converting between data types. Typing gdal_translate provides a full help message.


Command Line Script


gdal_translate [-of format] image_in image_out


Python Procedure


None provided.



Parameters



format The following formats are supported:
VRT: Virtual Raster
GTiff: GeoTIFF
HFA: Erdas Imagine Images (.img)
InfoSAR: InfoSAR NetCDF Images (.nc)
SAR_CEOS: CEOS SAR Image
CEOS: CEOS Image
ELAS: ELAS
AIG: Arc/Info Binary Grid
AAIGrid: Arc/Info ASCII Grid
SDTS: SDTS Raster
DTED: DTED Elevation Raster
PNG: Portable Network Graphics
JPEG: JPEG JFIF
MEM: In Memory Raster
JDEM: Japanese DEM (.mem)
GIF: Graphics Interchange Format (.gif)
ESAT: Envisat Image Format (.N1)
BSB: Maptech BSB Nautical Charts
XPM: X11 PixMap Format (.xpm)
PNM: Portable Pixmap Format (netpbm)
DOQ1: USGS DOQ (Old Style)
DOQ2: USGS DOQ (New Style)
ENVI: ENVI .hdr Labelled
EHdr: ESRI .hdr Labelled
PAux: PCI .aux Labelled
MFF: Atlantis MFF Raster
MFF2: Atlantis MFF2 (HKV) Raster
EFF: Eosat Fast Format
FujiBAS: Fuji BAS Scanner Image
FIT: FIT image
USGSDEM: USGS Optional ASCII DEM
GXF: GeoSoft Grid Exchange Format

The default output format is GeoTIFF.


gisload


Purpose


Returns the class containing the GIS information stored in an InfoSAR netcdf file.


Command Line Script


None provided.


Python Procedure


gis_class = gisload('image_in')



gissave


Purpose


Saves/updates the class containing the GIS information stored in an InfoSAR netcdf file.


Command Line Script


None provided.


Python Procedure


gissave('image_out', gis_class)



insert


Purpose


Inserts a sub-image into a larger image at the given offsets.


Command Line Script


insert.py image_in insert_in image_out [woffset=] [hoffset=]


Python Procedure


See save.



Parameters



woffset integer, default None.


hoffset integer, default None.


layer_combine


Purpose


Combines image layers (held in a set of seperate images) into a single file. All input images must be of the same width and height.


Command Line Script


layer_combine.py image1_in image2_in ... image_out [tilesize=] [overlap=]
[tmpdir=]


Python Procedure


None provided.



Parameters



tilesize integer, default 128. A tilesize of 128 x 128 is used.


overlap integer, default 16. To prevent obvious joins between tiles, an overlap of 16 is used.


tmpdir directory, default "/tmp/" or ``C:/TEMP''. Intermediate results are written here.


layer_split


Purpose


Splits a multi-layered image into a numbered set of images corresponding to the individual layers. Results are written into the files "image_out_000.nc", "image_out_001.nc", ...


Command Line Script


layer_split.py image_in image_out [tilesize=] [overlap=] [tmpdir=]


Python Procedure


None provided.



Parameters



tilesize integer, default 128. A tilesize of 128 x 128 is used.


overlap integer, default 16. To prevent obvious joins between tiles, an overlap of 16 is used.


tmpdir directory, default "/tmp/" or ``C:/TEMP''. Intermediate results are written here.


load


Purpose


Loads an image file and its GIS information (if available).

Load returns a list of length two. The first element is the GDAL file as a Numeric array, while the second element is a class containing the GIS information.

Load loads the subimage of dimensions width by height starting at the pixel location given by woffset and hoffset.


Command Line Script


None provided.


Python Procedure


array_out, gis_class = load('image_in' [,woffset=] [,hoffset=] [,width=]
[,height=])




Parameters



woffset integer, default 0.


hoffset integer, default 0.


width integer, default None.


width integer, default None.


makebitmap


Purpose


Converts a Numeric array to an RGB array. The array can then be saved in a variety of formats suitable for display in common graphics packages.

For each layer of the image, values that lies in the range min to max are mapped into the range 0 to 255. If min or max are not specified then the parameter sd is used with the following mapping:
$\mu - {\tt sd}\times\sigma \rightarrow 0$
$\mu + {\tt sd}\times\sigma \rightarrow 255$
where $\mu$ is the mean and $\sigma$ is the variance of the data. A value of sd = 0 has the special meaning of
minimum $\rightarrow 0$
maximum $\rightarrow 255$

Complex data cannot be directly displayed as a bitmap and so must be converted to real data first. This is done by the option cmpl2real.


Command Line Script


See totiff.py.


Python Procedure


array_out = makebitmap(array_in [,cmpl2real=] [,sd=] [,min=] [,max=]
[,verbose=])




Parameters



cmpl2real Chooses from a set of methods for converting the complex image to a real one: ``abs'' absolute value.
``phase'' Phase of complex number.
``real'' Real part.
``imag'' Imaginary part.
The default is "abs".



sd real32, default 2.0.


min real32, default None.


max real32, default None.


verbose integer, default 0. If set to 1 then the estimated min and max values are printed out.


nc2ascii


Purpose


Converts an InfoSAR netcdf file into an ASCII file.


Command Line Script


nc2ascii.py image_in ascii_out


Python Procedure


None provided.



nc2raw


Purpose


Converts an InfoSAR netcdf file into a raw data file.
Use the option byteswap=1 to transforms big-endian to little-endian data.


Command Line Script


nc2raw.py image_in raw_out [tilesize=] [overlap=] [tmpdir=]


Python Procedure


None provided.



Parameters



tilesize integer, default 128. A tilesize of 128 x 128 is used.


overlap integer, default 16. To prevent obvious joins between tiles, an overlap of 16 is used.


tmpdir directory, default "/tmp/" or ``C:/TEMP''. Intermediate results are written here.


numload


Purpose


Loads an image file, without the GIS information.

Numload returns the GDAL file as a Numeric array. Numload loads the subimage of dimensions width by height starting at the pixel location given by woffset and hoffset.


Command Line Script


None provided.


Python Procedure


array_out = numload('image_in' [,woffset=] [,hoffset=] [,width=] [,height=])



Parameters



woffset integer, default 0.


hoffset integer, default 0.


width integer, default None.


width integer, default None.



raw2nc


Purpose


Converts an InfoSAR netcdf file into a raw data file. The type of data must be specified.


Command Line Script


raw2nc.py raw_in image_out type= [byteswap=] [header=] [layers=] [verbose=]
[tilesize=] [overlap=] [tmpdir=]


Python Procedure


None provided



Parameters



type Type is one of:
'D' Complex, Complex64
'F' Complex0, Complex16, Complex32, Complex8
'd' Float, Float64
'f' Float0, Float16, Float32, Float8
'l' Int
'b' Int0, Int8
's' Int16
'i' Int32



byteswap integer, default 1. When set to 1 the routine transforms big-endian to little-endian data.

Depending on how your images are constructed, it is possible that you will need to reverse the order of the bytes. To see whether this is the case, it is suggested that you look at the statistics of the converted image to check that the values it reports look sensible; if not, you probably need to swap the byte order. A visual inspection may also prove sufficient.


header integer, default 0. When set to 0 the routine skips the header (bytes).


layers integer, default 1. To set the number of layers - Band sequential (BSQ) format.


verbose integer, default 0. When set to 0 the routine turns off information messages.


tilesize integer, default 128. A tilesize of 128 x 128 is used.


overlap integer, default 16. To prevent obvious joins between tiles, an overlap of 16 is used.


tmpdir directory, default "/tmp/" or ``C:/TEMP''. Intermediate results are written here.



save


Purpose


Saves the Numeric array and class containing the GIS information in an InfoSAR netcdf file. Options are available to save the array at given offsets and in other GDAL compatible output formats.


Command Line Script


None provided.


Python Procedure


save(array_in, 'image_out' [,gis=] [,woffset=] [,hoffset=] [,format=])



Parameters



gis Optional GIS information to be saved to the image file header. This variable is returned from a call to the load function.


woffset integer, default None. If woffset or hoffset are set, it is assumed that emptyfile() has already been called to initialise the image size.


hoffset integer, default None. If woffset or hoffset are set, it is assumed that emptyfile() has already been called to initialise the image size.


format The following formats are supported:
VRT: Virtual Raster
GTiff: GeoTIFF
HFA: Erdas Imagine Images (.img)
InfoSAR: InfoSAR NetCDF Images (.nc)
SAR_CEOS: CEOS SAR Image
CEOS: CEOS Image
ELAS: ELAS
AIG: Arc/Info Binary Grid
AAIGrid: Arc/Info ASCII Grid
SDTS: SDTS Raster
DTED: DTED Elevation Raster
PNG: Portable Network Graphics
JPEG: JPEG JFIF
MEM: In Memory Raster
JDEM: Japanese DEM (.mem)
GIF: Graphics Interchange Format (.gif)
ESAT: Envisat Image Format (.N1)
BSB: Maptech BSB Nautical Charts
XPM: X11 PixMap Format (.xpm)
PNM: Portable Pixmap Format (netpbm)
DOQ1: USGS DOQ (Old Style)
DOQ2: USGS DOQ (New Style)
ENVI: ENVI .hdr Labelled
EHdr: ESRI .hdr Labelled
PAux: PCI .aux Labelled
MFF: Atlantis MFF Raster
MFF2: Atlantis MFF2 (HKV) Raster
EFF: Eosat Fast Format
FujiBAS: Fuji BAS Scanner Image
FIT: FIT image
USGSDEM: USGS Optional ASCII DEM
GXF: GeoSoft Grid Exchange Format

The default format is 'InfoSAR'.


totiff


Purpose


Converts image data to a TIFF bitmap, suitable for display in common graphics packages.

For each layer of the image, values that lies in the range min to max are mapped into the range 0 to 255. If min or max are not specified then the parameter sd is used with the following mapping:
$\mu - {\tt sd}\times\sigma \rightarrow 0$
$\mu + {\tt sd}\times\sigma \rightarrow 255$
where $\mu$ is the mean and $\sigma$ is the variance of the data. A value of sd = 0 has the special meaning of
minimum $\rightarrow 0$
maximum $\rightarrow 255$

Complex data cannot be directly displayed as a bitmap and so must be converted to real data first. This is done by the option cmpl2real.


Command Line Script


totiff.py image_in image_out.tif [cmpl2real=] [sd=] [min=] [max=]
[verbose=] [tilesize=] [overlap=] [tmpdir=]


Python Procedure


See procedure makebitmap.



Parameters



cmpl2real Chooses from a set of methods for converting the complex image to a real one: ``abs'' absolute value.
``phase'' Phase of complex number.
``real'' Real part.
``imag'' Imaginary part.
The default is "abs".



sd real32, default 2.0.


min real32, default None.


max real32, default None.


verbose integer, default 0. If set to 1 then the estimated min and max values are printed out.


tilesize integer, default 128. A tilesize of 128 x 128 is used.


overlap integer, default 16. To prevent obvious joins between tiles, an overlap of 16 is used.


tmpdir directory, default "/tmp/" or ``C:/TEMP''. Intermediate results are written here.



InfoSAR Ltd