DESCRIPTION

r.out.gdal allows a user to export a GRASS raster map layer into any GDAL supported raster map format. For possible metaopt parameters see the individual supported formats pages on the GDAL website. The createopt parameter may be used to create TFW or World files ("TFW=YES","WORLDFILE=ON").

r.out.gdal also supports the export of multiband rasters as a group, when the imagery group's name is entered as input. (created imagery groups with the i.group module)

As with most GRASS raster modules, the current region extents and region resolution are used, and a MASK is respected if present. Use g.region's "align=", or "rast=" options if you need to realign the region settings to match the original map's before export.

SUPPORTED RASTER FORMATS

The set of supported raster formats written by r.out.gdal depends on the local GDAL installation. Available may be (incomplete list):

  AAIGrid: Arc/Info ASCII Grid
  BMP: MS Windows Device Independent Bitmap
  BSB: Maptech BSB Nautical Charts
  DTED: DTED Elevation Raster
  ELAS: ELAS
  ENVI: ENVI .hdr Labelled
  FIT: FIT Image
  GIF: Graphics Interchange Format (.gif)
  GTiff: GeoTIFF
  HDF4Image: HDF4 Dataset
  HFA: Erdas Imagine Images (.img)
  JPEG2000: JPEG-2000 part 1 (ISO/IEC 15444-1)
  JPEG: JPEG JFIF
  MEM: In Memory Raster
  MFF2: Atlantis MFF2 (HKV) Raster
  MFF: Atlantis MFF Raster
  NITF: National Imagery Transmission Format
  PAux: PCI .aux Labelled
  PCIDSK: PCIDSK Database File
  PNG: Portable Network Graphics
  PNM: Portable Pixmap Format (netpbm)
  VRT: Virtual Raster
  XPM: X11 PixMap Format

NOTES

When writing out multi-band GeoTIFF images for users of ESRI software or ImageMagick, the interleaving mode should be set to "pixel" using createopt="INTERLEAVE=PIXEL". BAND interleaving is slightly more efficient, but not supported by some applications. This issue only arises when writing out multi-band imagery groups. Some software may not recognize all of the compression methods available.

To specify multiple options use a comma separated list (createopt="TFW=YES,COMPRESS=DEFLATE").

Out of the GDAL data types, the closest match for GRASS CELL, FCELL and DCELL rasters are respectively Int32, Float32 and Float64. These are not exact equivalents, but they will preserve the maximum possible data range and number of decimal places for each respective GRASS raster data type. Please keep in mind that not all CELL rasters will require Int32 - e.g., 0-255 CELL raster are covered by the Byte type as well. Moreover, some GDAL-supported formats do not support all the data types possible in GDAL and GRASS. Use r.info to check the data type and range for your GRASS raster, refer to specific format documentation (on the GDAL website), format vendor's documentation, and e.g. the Wikipedia article Typical boundaries of primitive integral types for details.

Ranges of GDAL data types

  GDAL data type	       minimum  	maximum

  Byte  			     0  	    255
  UInt16			     0  	 65,535
  Int16, CInt16 	       -32,768  	 32,767
  UInt32			     0    4,294,967,295
  Int32, CInt32 	-2,147,483,648    2,147,483,647
  Float32, CFloat32	       -3.4E38  	 3.4E38
  Float64, CFloat64	     -1.79E308         1.79E308

If there is a need to keep file sizes small, use the simplest data type covering the data range of the raster(s) to be exported, e.g., if suitable use Byte rather than UInt16; use Int16 rather than Int32; or use Float32 rather than Float64. In addition, the COMPRESS createopt used can have a very large impact on the size of the output file.

Improving GeoTIFF compatibility

To create a highly compatibility GeoTIFF with various other GIS software packages, it is recommended to keep the GeoTIFF file as simple as possible. You will have to experiment with which options your software is compatible with, as this varies widely between vendors and versions. Long term, the less metadata you have to remove the more self-documenting (and useful) the dataset will be.

Here are some things to try:

EXAMPLES

Export the integer raster roads map to GeoTIFF format:

r.out.gdal input=roads output=roads.tif type=UInt16

Export a DCELL raster map in GeoTIFF format suitable for ESRI software:

r.out.gdal in=elevation.10m out=ned_elev10m.tif type=Float64 createopt="TFW=YES"

Export R,G,B imagery bands in GeoTIFF format suitable for ESRI software:

i.group group=nc_landsat_rgb input=lsat7_2002_30,lsat7_2002_20,lsat7_2002_10
r.out.gdal in=nc_landsat_rgb out=nc_landsat_rgb.tif type=Byte createopt="INTERLEAVE=PIXEL,TFW=YES"

Export the floating point raster elevation map to ERDAS/IMG format:

r.out.gdal input=elevation.10m output=elev_dem10.img format=HFA type=Float32

Export group of image maps as multi-band file

g.list group
i.group group=tm7 subgroup=tm7 input=tm7_10,tm7_20,tm7_30,tm7_40,tm7_50,tm7_60,tm7_70
i.group -l tm7
r.out.gdal tm7 type=UInt16 out=lsat_multiband.tif
gdalinfo lsat_multiband.tif

GDAL RELATED ERROR MESSAGES

SEE ALSO

The GDAL supported formats page.
r.out.ascii, r.out.arc, r.out.bin, r.out.mat, r.out.png, r.out.ppm, r.out.tiff
r.out.gdal.sh
(old shell script version using gdal_translate)

REFERENCES

GDAL Pages: http://www.gdal.org

AUTHOR

Vytautas Vebra (oliver4grass at gmail.com)

Last changed: $Date$