r.in.gdal - Import GDAL supported raster file into a binary raster map layer.
r.in.gdal [-oefk] [input=name] [output=name] [band=integer] [target=string] [title="phrase"] [location=string] [--overwrite] [--verbose] [--quiet]
- Override projection (use location's projection)
- Extend location extents based on new dataset
- List supported formats and exit
- Keep band numbers instead of using band color names
- Allow output files to overwrite existing files
- Verbose module output
- Quiet module output
- Raster file to be imported
- Name for output raster map
- Band to select (default is all bands)
- Name of location to read projection from for GCPs transformation
- Title for resultant raster map
- Name for new location to create
r.in.gdal allows a user to create a (binary) GRASS raster map layer,
or imagery group,
from any GDAL supported raster map format, with an optional title. The
imported file may also be optionally used to create a new location.
GDAL supported raster formats
Full details on GDAL supported formats are available at:
Selected formats of more than 45 supported formats:
Long Format Name Code Creation Georeferencing Maximum File Size
Arc/Info ASCII Grid AAIGrid Yes Yes No limits
Arc/Info Binary Grid AIG No Yes --
AIRSAR Polarimetric AIRSAR No No --
Microsoft Windows Device Independent Bitmap (.bmp) BMP Yes Yes 4GiB
BSB Nautical Chart Format (.kap) BSB No Yes --
VTP Binary Terrain Format (.bt) BT Yes Yes --
CEOS (Spot for instance) CEOS No No --
First Generation USGS DOQ (.doq) DOQ1 No Yes --
New Labelled USGS DOQ (.doq) DOQ2 No Yes --
Data (.dt0, .dt1) DTED No Yes --
ERMapper Compressed Wavelets (.ecw) ECW Yes Yes
ESRI .hdr Labelled EHdr No Yes --
ENVI .hdr Labelled Raster ENVI Yes Yes No limits
Envisat Image Product (.n1) Envisat No No --
EOSAT FAST Format FAST No Yes --
FITS (.fits) FITS Yes No
Graphics Interchange Format (.gif) GIF Yes No 2GB
Arc/Info Binary Grid (.adf) GIO Yes Yes
GRASS Rasters GRASS No Yes --
TIFF / GeoTIFF (.tif) GTiff Yes Yes 4GiB
Hierarchical Data Format Release 4 (HDF4) HDF4 Yes Yes 2GiB
Erdas Imagine (.img) HFA Yes Yes No limits
Atlantis MFF2e HKV Yes Yes No limits
Image Display and Analysis (WinDisp) IDA Yes Yes 2GB
ILWIS Raster Map (.mpr,.mpl) ILWIS Yes Yes --
Japanese DEM (.mem) JDEM No Yes --
JPEG JFIF (.jpg) JPEG Yes Yes 4GiB (max dimentions 65500x65500)
JPEG2000 (.jp2, .j2k) JPEG2000 Yes Yes 2GiB
JPEG2000 (.jp2, .j2k) JP2KAK Yes Yes No limits
NOAA Polar Orbiter Level 1b Data Set (AVHRR) L1B No Yes --
Erdas 7.x .LAN and .GIS LAN No Yes 2GB
In Memory Raster MEM Yes Yes 2GiB
Atlantis MFF MFF Yes Yes No limits
Multi-resolution Seamless Image Database MrSID No Yes --
NDF NLAPS Data Format No Yes No limits
NITF NITF Yes Yes
NetCDF netCDF Yes Yes 2GB
OGDI Bridge OGDI No Yes --
PCI .aux Labelled PAux Yes No No limits
PCI Geomatics Database File PCIDSK Yes Yes No limits
Portable Network Graphics (.png) PNG Yes No
PCRaster (.map) PCRaster Yes No
Netpbm (.ppm,.pgm) PNM Yes No No limits
RadarSat2 XML (product.xml) RS2 No Yes 4GB
USGS SDTS DEM (*CATD.DDF) SDTS No Yes --
SAR CEOS SAR_CEOS No Yes --
USGS ASCII DEM (.dem) USGSDEM No Yes --
X11 Pixmap (.xpm) XPM Yes No
r.in.gdal attempts to preserve projection information when importing
datasets if the source format includes projection information, and if
the GDAL driver supports it. If the projection of the source dataset does
not match the projection of the current location r.in.gdal will
report an error message (Projection of dataset does not appear to
match current location) and then report the PROJ_INFO parameters of
the source dataset.
If the user wishes to ignore the difference between the apparent coordinate
system of the source data and the current location, they may pass the
-o flag to override the projection check.
If the user wishes to import the data with the full projection definition,
it is possible to have r.in.gdal automatically create a new location based
on the projection and extents of the file being read. This is accomplished
by passing the name to be used for the new location via the location
parameter. Upon completion of the command, a new location will have been
created (with only a PERMANENT mapset), and the raster will have been
imported with the indicated output name into the PERMANENT mapset.
Support for GCPs: In case the image contains GCPs they are written to a
POINTS file within an imagery group. They can directly be used for
i.rectify. The target option allows to
automatically re-project the GCPs from their own projection into another
projection read from the PROJ_INFO file of the location name
I plan to make a variety of improvements to r.in.gdal in the future
including support for reporting everything known about a dataset if the
output parameter is not set.
The r.in.gdal comand does support the following features, as long as
the underlying format driver supports it:
- Color Table
- Bands with associated colortables will have the color tables transferred.
Note that if the source has no colormap, r.in.gdal in GRASS 5.0 will emit
no colormap. Use r.colors map=... color=grey to assign a greyscale colormap.
In a future version of GRASS r.in.gdal will likely be upgraded to automatically
emit greyscale colormaps.
- Data Types
- Most GDAL data types are supported. Float32 and Float64 type bands
are translated as GRASS floating point cells (but not double precision ...
this could be added if needed), and most other types are translated as
GRASS integer cells. This includes 16bit integer data sources. Complex
(some SAR signal data formats) data bands are translated to two floating
point cell layers (*.real and *.imaginary).
- If the dataset has affine georeferencing information, this will be used
to set the north, south, east and west edges. Rotational coefficients will
be ignored, resulting in incorrect positioning for rotated datasets.
- The datasets projection will be used to compare to the current location
or to define a new location. Internally GDAL represents projections in
OpenGIS Well Known Text format. A large subset of the total set of GRASS
projections are supported.
- Null Values
- Raster bands for which a null value is recognised by GDAL will have
the null pixels transformed into GRASS style nulls during import. Many
generic formats (and formats poorly supported by GDAL) do not have a way
of recognising null pixels in which case r.null should be used after the
- Datasets that have Ground Control Points will have them imported as
a POINTS file associated with the imagery group. Datasets with only one
band that would otherwise have been translated as a simple raster map
will also have an associated imagery group if there are ground control points.
The coordinate system of the ground control points is reported by r.in.gdal
but not preserved. It is up to the user to ensure that the location
established with i.target has a compatible coordinate system before using
the points with i.rectify.
To avoid that the GTOPO30 data are read incorrectly, you can add a new line
"PIXELTYPE SIGNEDINT" in the .HDR to force interpretation of the file as
signed rather than unsigned integers. Then the .DEM file can be imported.
Finally, e.g. the 'terrain' color table can be assigned to the imported map
To import GLOBE DEM tiles
(approx 1km resolution, better than GTOPO30 DEM data), the user has to download
additionally the related HDR file(s).
Finally, e.g. the 'terrain' color table can be assigned to the imported map with r.colors.
To import Worldclim data, the following
line has to be added to each .hdr file:
The import of HDF bands requires the specification of the individual bands
as seen by GDAL:
# Example MODIS FPAR
SUBDATASET_1_DESC=[1200x1200] Fpar_1km MOD_Grid_MOD15A2 (8-bit unsigned integer)
SUBDATASET_2_DESC=[1200x1200] Lai_1km MOD_Grid_MOD15A2 (8-bit unsigned integer)
# import of first band, here FPAR 1km:
r.in.gdal HDF4_EOS:EOS_GRID:"MOD15A2.A2003153.h18v04.004.2003171141042.hdf":MOD_Grid_MOD15A2:Fpar_1km \
# ... likewise for other HDF bands in the file.
"ERROR: Input map is rotated - cannot import."
In this case the image must be first externally rotated, applying the rotation info stored in
the metadata field of the raster image file. For example, the
gdalwarp software can be used
to transform the map to North-up (note, there are several gdalwarp parameters to select the
gdalwarp rotated.tif northup.tif
"ERROR: Projection of dataset does not appear to match the current location."
You need to create a location whose projection matches the data you
wish to import. Try using location parameter to create a new location based
upon the projection information in the file. If desired, you can then re-project
it to another location with r.proj.
GDAL Pages: http://www.gdal.org/
Frank Warmerdam (email).
Last changed: $Date: 2008-02-24 07:18:43 -0800 (Sun, 24 Feb 2008) $
Main index - raster index - Full index
© 2003-2008 GRASS Development Team