GRASS 6 Tutorial/Raster data management

From GRASS-Wiki
< GRASS 6 Tutorial
Revision as of 01:47, 9 August 2013 by Madi (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Raster data management

Data Import

In a similar way to the vector data management, the import and export of raster data is underpinned by GDAL. As such, the modules, r.in.* and r.out.* and specifically, r.in.gdal and r.out.gdal are used. The module r.extenal can be used in lieu of importing a raster into GRASS.

A Geotiff can be imported into GRASS using the command line (input represents the full or relative path to the raster file you want to import; output is its raster name in GRASS). The same can be achieved using the GUI.

r.in.gdal input=elev_input_state500m.tif output=elev_input_state500m

Grass raster import.png


Sometimes, you need to define the region of the Mapset to the extent of your raster. For instance, using the above-mentioned example, you would simply:

g.region rast=elev_input_state500m

A common issue that users are faced with is how to import several GeoTiffs? Obviously the above steps can be repeated using the GUI or copy-pasting the command line or more simply using the following BASH for loop:

for file in `ls *.tif`
 do
  r.in.gdal input=$file output=${file%.tif}
done


Note - that when you run r.in.gdal, the full extent of the map is imported