Saturday, June 28, 2014

Using ISIS 2/3 image cubes in GIS software

Below contains recommended methods to directly use or convert ISIS 3 (and ISIS v2) into a well-formed GIS compatible format.
Recommended Rules of the Road:
  • Before ingesting any file (PDS, ISIS, other) into a GIS it should be map projected.
  • If file is to meant for visual purposes only (e.g. mapping on), it is highly recommended to stretch the images to 8bit (see below)
  • Don't use funky projections (e.g.; ISIS's oblique cylindrical)
  • Best to use positive East longitudes and a –180 to 180 longitude system.
  • For Longitude systems 180 or 360 it is highly recommended to:
    • if the set longitude system = 180 (-180 to 180), then set center longitude = 0 (or center of the image).
    • if the set longitude system = 360 (0 to 360), then set center longitude = 180 (or center of the image).
  • Don't use ISIS's method, isis2std, to convert files to Tiffs, Jpeg2000, Jpgs or PNGs. Why? It does not create a fully-formed GIS format with defined projection. It supports a GIS worldfile (simply the image registration in the current projected Cartesian plane) but not the projection definition.
  • Do use GDAL's tools, gdal_translate, to convert files from ISIS3 to one of many output formats (GeoTiff, GeoJpeg2000, Jpeg, PNG, ENVI, ect.).
Direct support: There is fairly good support for reading ISIS3 cubes (and version 2) files in the GDAL library. This means packages which use GDAL can usually read most map projected ISIS 2,3 and PDS files directly. This includes packages like QGIS, ArcMap GIS, Mirone, Saga GIS, Opticks, GRASS, and soon GMT, more). Since the GDAL reader only support one NoDATA value for 32bit and 16bit files there might be issues for the application to understand the valid data range. In this case, it is best to use stretch in ISIS to set the 5 supported special pixel values to valid or NoDATA (see below).
Conversion support: As stated above, I recommend using the GDAL utility application gdal_translate to convert from ISIS2, 3 or PDS format to another format for your application. Forth coming thread on GDAL tips for planetary data…
a few conversion examples:
  • gdal_translate –of GTiff input_32bit.cub output_32bit.tiff
  • gdal_translate –of GTiff input_16bit.cub output_16bit.tiff
  • gdal_translate –of GTiff input_8bit.cub output_8bit.tiff
  • gdal_translate –of Jpeg –ot Byte –scale input.cub output_8bit.jpg
  • gdal_translate –of Jp2kak –co quality=100 input_16bit.cub output_16bit.jp2
Conversion from 32bit to 8bit in ISIS before conversion:
My currently favorite method to convert to 8bit in ISIS (before using gdal to convert to geoTiff or GeoJpeg2000 or other format). I can't recommend the ISIS program bit2bit since it pushes valid data which is clipped into NoDATA (not good for viewing the image).

ISIS Stretch method 1:>stretch from=input.cub to=output_8bit.cub+8bit+1:254 USEPERCENTAGES=true pairs="0:1 100:254" null=0 lis=1 lrs=1 his=255 hrs=255
    This allows you to specify input percentages for the mapping pairs. Thus when
    USEPERCENTAGES=true is set pairs="0:1 100:254" means:
    map 0% to 1 (or the file's min value to 1) and 100% to 254 (file's max value).

ISIS Stretch method 2:This also means you can apply a recommended 0.5% clip to remove the potential extraneous lows and highs like:
>stretch from=input.cub to=output_8bit.cub+8bit+1:254 USEPERCENTAGES=true pairs="0:1 0.5:1 99.5:254 100:254" null=0 lis=1 lrs=1 his=255 hrs=255

Now once in an 8bit format convert to GeoTiff or other for easy and fast viewing. For huge files take advantage of BigTiff or Jpeg2000 lossy support
  • gdal_translate –ot GTiff –co Bigtiff=if_safer –co tiled=yes input_8bit.cub output_8bit.tif
  • gdal_translate –ot Jp2kak input_8bit.cub output_8bit.jp2

----simple example Csh Script to force output scale to 1 to 255.
mag{90}> more /usgs/cdev/contrib/bin/to8bit_gdal_tif.csh
Code: 
#!/bin/csh
#usage: to8bit_gdal_tif.csh input.ext output.tif
#Note the use of $3 in gdal_translate which just allows you to add in other options. By default it will just be blank.
set in=$1
set out=$2

set stats = `gdalinfo -stats $in > /tmp/xxxtemp_stats.junk`
set min = `cat /tmp/xxxtemp_stats.junk | grep MINIMUM | awk -F= '{print $2}' | sed 's/ //g'`
set max = `cat /tmp/xxxtemp_stats.junk | grep MAXIMUM | awk -F= '{print $2}' | sed 's/ //g'`

gdal_translate -ot byte -of GTIFF -co compress=lzw -ot Byte $3 -a_nodata 0 -scale $min $max 1 255 $in $out
/bin/rm -f /tmp/xxxtemp_stats.junk
 
-Trent

No comments:

Post a Comment