# Batch converting geotiff to cube

**URL:** <https://openplanetary.discourse.group/t/batch-converting-geotiff-to-cube/638>\
**Category:** Tools and Web Services\
**Created:** [May 13, 2023, 10:14pm UTC](https://openplanetary.discourse.group/t/batch-converting-geotiff-to-cube/638 "2023-05-13T22:14:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trent\_Hare](https://yyz2.discourse-cdn.com/free1/user_avatar/openplanetary.discourse.group/trent_hare/32/303_2.png) [@Trent\_Hare](https://openplanetary.discourse.group/u/Trent_Hare)\
**Post date:** [May 13, 2023, 10:14pm UTC](https://openplanetary.discourse.group/t/batch-converting-geotiff-to-cube/638/1 "2023-05-13T22:14:46Z")

</div>

> A transfer from the original Astrodiscuss forum (from Melcore79)

Hello,  
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
End_Group

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

```

End\_Object

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\>  
End\_Group  
End\_Object

Object = Label  
Bytes = 1416  
End\_Object

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

---

<div class="post-metadata">

**Author:** ![Trent\_Hare](https://yyz2.discourse-cdn.com/free1/user_avatar/openplanetary.discourse.group/trent_hare/32/303_2.png) [@Trent\_Hare](https://openplanetary.discourse.group/u/Trent_Hare)\
**Post date:** [May 13, 2023, 10:26pm UTC](https://openplanetary.discourse.group/t/batch-converting-geotiff-to-cube/638/2 "2023-05-13T22:26:06Z")

</div>

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.

[https://isis.astrogeology.usgs.gov/Application/presentation/Tabbed/cubeatt/cubeatt.html](https://isis.astrogeology.usgs.gov/Application/presentation/Tabbed/cubeatt/cubeatt.html)  
`> 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:

- [ISIS3 – USGS Astrogeology ISIS Cube (Version 3) — GDAL documentation](https://gdal.org/drivers/raster/isis3.html)  
PDS4:
- [PDS4 – NASA Planetary Data System (Version 4) — GDAL documentation](https://gdal.org/drivers/raster/pds4.html)
- [Raster Introduction for PDS4 Conversion Using GDAL · pds-data-dictionaries/ldd-cart Wiki · GitHub](https://github.com/pds-data-dictionaries/ldd-cart/wiki/Raster-Introduction-for-PDS4-Conversion-Using-GDAL)
