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

Planetary GIS – why start a blog now?

For more than 10 years, apparently since 2002, I have used various discussion sites to list common GIS issues for the community. To get the ball rolling, many posts were just questions sent to me in emails that I would try to answer. I actually started posting the questions from a generic user called “planetary researcher” and then logged in as myself, “thare”, and answered the question. Using the wayback machine, it appears in the second discussion site incarnation, the top read threads included answers to:
  • How do I read the MOLA MEGDR 128 [pixels/degree] images?
  • How to get a level 2 ISIS image into a GIS?
  • Polar glitches in the MDIM2.1 files?
Obviously the Mars MOLA topography was still the new kid on the block and very popular (frankly still is). And while some GISs now have direct support for ISIS files, loading map projected ISIS and PDS files is still a common issue for GIS users. And the “polar” glitch thread was more about the new MDIM2.1 projection style changing to Equirectangular from Sinusoidal and the fact the Jpeg images had too many pixels for Photoshop CS ( version 8 ) . BTW, Looking at those “small” file sizes now, newer images released continue to explode in pixel count and size. We now have several 1TB mosaics in the community! The challenge is not really how to open them, but how to deliver them.

Anyway, that second discussion site incarnation lasted only year before the ISIS started a discussion forum and all the GIS topics were co-located with the ISIS topics. But in that one year more than 100 thousand threads were viewed. I assume many hits were from general GIS users who quickly bounced once they figured out we were discussing planets (or false hits from indexers).

Anyway, to get to the point, our latest discussion software platform has been down for about a week from an apparent PHP breach. While many topics even on the latest site become stale, there are still plenty of useful threads for folks to stumble upon. I will start transferring some of the those older topics (but still relevant) and post new topics into this blog. We still get plenty of email questions weekly which posts here can be based on. I don’t see using a blogging tool really any better than a discussion site for keeping threads from becoming stale, but perhaps I can remove or edit sections more easily.

For my first real post I will try to summarize how to load/convert ISIS files – again.

-Trent