Note: this is a post from 2009, transferred to this new board and update for 2019.
GDAL. This open source raster library (used in many apps) has some support for map projected PDS3, PDS4, ISIS2, ISIS3, VICAR, FITS reading (and some write capabilities). It can export raw, ASCII or a tons of other formats like GeoTiff. It tries to maintain map projection information and some metadata to output formats that allow it. The GDAL utility applications have stretching (scaling options), map projection transformation support, clipping, resampling and mosaic capabilities.
There are many binary versions available, but our current favorite is to use anaconda. First download and install miniconda installed or anaconda installed, then to get GDAL, run conda install -c conda-forge gdal libgdal
. While this works across all OSs, some Mac users still prefer the Mac GDAL binary Frameworks and Windows users like OSGeo4W
for the main gdal_translate help: http://gdal.org/gdal_translate.html
to see what formats are currently supported:
>gdal_translate --formats
convert input bit type = same output type in Tiff (ISIS2/3 cub example ):
>gdal_translate -of GTiff input.cub output.tif
- GTiff is the default format so you can actually skip “-of GTiff” in this case
16bit Tiff (truncate floats):
>gdal_translate -of GTiff -ot Int16 input.cub output.tif
16bit UInt Tiff (truncate ALL negative values and floats):
gdal_translate -ot UInt16 -of GTiff -a_nodata 0 input.cub output.tif
scaled 16bit Uint Tiff Good for 3D applications like Blender, Bryce, Vue, changes pixel values across a positive 16bit range:
gdal_translate -ot UInt16 -of GTiff -a_nodata 0 -scale -767 2296 1 65536 moon11s308_8.cub moon.tif
–output range has been scaled to: 1 65536. To set the same integer range for this example try (where 2296 - -767 + 1 = 3064) or:
gdal_translate -ot UInt16 -of GTiff -a_nodata 0 -scale -767 2296 1 3064 moon11s308_8.cub moon.tif
output raw (ENVI compatible):
>gdal_translate -of ENVI input.cub out.raw
-This will create a ENVI header (*.hdr) with parameters spelled out
stretch to PNG 8bits and save out PNG worldfile (recommended):
>gdal_translate -of PNG -scale -co worldfile=yes input.cub out.png
manual stretch to PNG 8bits (no GIS worldfile):
>gdal_translate -of PNG -scale in_min in_max out_min out_max input.cub out.png
*notes I use output as 1 to 255 so that 0 is maintained as NULL - example:
>gdal_translate -of PNG -scale 0.0232 0.12 1 255 -a_nodata 0 input.cub out.png
scale (resize) to PNG 8bits at 10% original size for browse image:
>gdal_translate -of PNG -scale -size 10% 10% input.cub out_browse.png
scale (resize) to JPG 8bits at 100x200 pixels for web image (aspect not maintained):
>gdal_translate -of JPEG -scale -size 100 200 input.cub out100x200.jpg
ESRI ASCII Grid format:
>gdal_translate -of AAGrid input.cub output.asc
information about image:
> gdalinfo input.cub
stats about image:
>gdalinfo -stats input.cub
min/max range:
>gdalinfo -mm input.cub
To project to new projection use the program gdalwarp .