Batch converting geotiff to cube

A transfer from the original Astrodiscuss forum (from Melcore79)

I am putting together a PDS package and would like to support both ISIS and ArcGIS. I currently have a way to generate geoTIFFs with a label file that allows me to open them in ISIS, but would rather the package store geoTIFFS for ArcGIS users and cubes for ISIS users. There are other reasons for providing two different formats, one of which is ISIS only supports square pixels whereas ArcGIS by default has rectangular pixels.

For each geoTIFF I have a label file that allows me to open a geoTIFF using qview. From there I can choose “File->Save As” and then type the name. However, I currently have >500 images and would rather not do this for each file. Is there a way to use scripts to open the label and then save a cube, preferably with the same name? We are intending to make this a standard final step before archiving the cubes to the PDS, so I really need a way to make this easy. I’ve searched though the online documentation and can’t find an ISIS program that will help me, and qview apparently doesn’t support arguments.

I am using version 4.1.1 of ISIS

If it helps, here’s the label file

(isis) N1563651897$ cat LEADEQ-N1563651897-IoverF-ISIS-v1.lbl
Object = IsisCube
Object = Core
StartByte = 1282
^Core = LEADEQ-N1563651897-IoverF-ISIS-v1.tif
Format = BandSequential

Group = Dimensions
  Samples = 505
  Lines   = 501
  Bands   = 1

Group = Pixels
  Type       = Real
  ByteOrder  = Lsb
  Base       = 0.0
  Multiplier = 1.0


Group = Mapping
TargetName = Tethys
EquatorialRadius = 535600.0
PolarRadius = 525800.0
LatitudeType = Planetocentric
LongitudeDirection = PositiveEast
LongitudeDomain = 360
MinimumLatitude = -14.9120809999999953
MinimumLongitude = 274.197937000000024
MaximumLatitude = 3.04291899999999993
MaximumLongitude = 292.296290293413165
ProjectionName = SimpleCylindrical
CenterLongitude = 0.0
CenterLatitude = 0.0
CenterLatitudeRadius = 535600.0
UpperLeftCornerX = 2563197.78359359642
UpperLeftCornerY = 28445.1565237518262
PixelResolution = 335.016054431045063 <meters/pixel>
Scale = 27.9030910609858083 <pixels/degree>

Object = Label
Bytes = 1416

Object = History
Name = IsisCube
StartByte = 1
Bytes = 316
^History = LEADEQ-N1563651897-IoverF-ISIS-v1.History.IsisCube

Here are some tips for ISIS (assuming your files are ISIS compatible). To simply convert your ISIS-labeled Tiffs to cubes you can run cubeatt.
> cubeatt from=in.cub to=out.cub+BandSequential

Note the use of Band Sequential makes sure the output cube is NOT tiled. Images with tiles and compression are not allowed in the PDS.

GDAL also has some basic support to create ISIS cubes.
> gdal_translate -of ISIS3 -co TILED=NO in_geo.tif out_bsq.cub

I know you want to support both ISIS users and GIS users. So I would actually recommend archiving uncompressed GeoTIFFs with ISIS3 detached labels. You can see that in action using:

> gdal_translate -of ISIS3 -co DATA_LOCATION=GEOTIFF -co TILED=NO in.cub out.lbl
This will create an ISIS3+ label and GeoTIFF to hold the pixels. And now optionally create a detached XML PDS4 label for the GeoTIFF also (likely needs a good PDS4 label template – see links below)
`> gdal_translate -of PDS4 -co CREATE_LABEL_ONLY=YES out.tif out.xml

lots of other options as listed here for ISIS3+ conversion: