Subsections

1 Import of GIS data

To better illustrate daily GIS life, we will show how to import a couple of different GIS files. A set of maps has been prepared for the workshop using data from the Spearfish area.

1 Starting GRASS with Spearfish

To start GRASS with Spearfish, type

     grass60

At the data selection screen, select ``spearfish60'' from the left and your mapset from the middle column (see section 2.3.1 if you haven't created this mapset yet). Then click ``Enter GRASS''.

2 Importing vector ESRI SHAPE files (TIGER 2000)

Selected TIGER 2000 shapefiles have been prepared for the workshop (package: tiger2000_latlong_nad83.tar.gz).

These SHAPE files are originally formatted as Latitude-Longitude/NAD83 (degree; EPSG code 4269). Before importing them into the Spearfish location, we have to reproject the maps to UTM in order to match the GRASS Spearfish sample dataset definitions (UTM zone 13N, NAD27/Clarke66; EPSG code 26713).

This can be efficiently done with the ogr2ogr tool. As the original files are lacking a .prj file, which carries the projection information, we assign it on the fly using the '-s_srs' (source spatial reference system) parameter. The target SRS is defined with '-t_srs'. To simplify the definition of the projections, we use EPSG code numbers which are internally expanded to the full definition. The order of command-line file specification is (maybe surprisingly) <output> <input>:

     ogr2ogr -s_srs "+init=epsg:4269" -t_srs "+init=epsg:26713" $\backslash$

               tgr46081lkA_UTM13_nad27.shp tgr46081lkA.shp

This step must be done for all LatLong TIGER 2000 SHAPE files. You can also skip this step, as we have prepared the package tiger2000_UTM13_nad27.tar.gz, which can be used directly. The included readme.html file explains the layer names and acronyms.

Vector data are imported by using v.in.ogr, many formats are accepted. SHAPE files are not stored in a topological format. The module v.in.ogr contains an internal ``topology engine'' which fixes a lot of common SHAPE file problems during import and generates topological information.

Now we can import the reprojected TIGER SHAPE files (shown here using the command line, you can also use the mouse by starting the command without parameters). We import the roads map (lkA) and the hydrography (lkH):

     v.in.ogr tgr46081lkA_UTM13_nad27.shp out=tgr2000_roads

     v.in.ogr tgr46081lkH_UTM13_nad27.shp out=tgr2000_hydro

     d.vect tgr2000_roads col=grey

     d.vect tgr2000_hydro col=aqua

To display, you can either select the imported maps in the GIS manager, use the command line or start qgis and select the maps there (using the Add GRASS vector map button).

Note: If the projection information is missing in the file (and you are sure that it corresponds to the projection of the GRASS location), you can use the '-o' flag to override the projection test.

3 Importing raster Erdas/IMG files (LANDSAT-7)

For the Spearfish area a LANDSAT scene has been prepared. It is already reprojected to UTM/NAD27 and subset to minimize the data size. The scene is split into three files (NIR: near infrared, MIR: middle infrared, TIR: thermal):

In order to import raster data to GRASS, use r.in.gdal (the output parameter for multichannel data is used as a prefix):

     r.in.gdal -e in=<image.img> out=<image>

The module verifies that the projection of the dataset matches that of the location. If the projections do not match, an error is issued. Sometimes such definition is not present in the dataset; if you are sure that it matches the location definition, the '-o' flag can be used to override the test. The '-e' flag can be used to expand the extent of the location to match that of the dataset. However, the map is imported completely in any case. For our Spearfish example we do:

     r.in.gdal -e in=spearfish_landsat7_NAD27_vis_ir.img out=tm

     g.rename rast=tm.6,tm.7

     r.in.gdal -e in=spearfish_landsat7_NAD27_tir.img out=tm6

     r.in.gdal -e in=spearfish_landsat7_NAD27_pan.img out=pan

To keep the numbering right, we rename tm.6 to the correct number tm.7.

To look at the multichannel maps, we can generate a RGB composite on the fly:

     g.region rast=tm.1 -p

     d.rgb b=tm.1 g=tm.2 r=tm.3

You should see the Spearfish area in near-natural colors.

4 Importing Raster GeoTIFF files

Data in the TIFF image files are either in GeoTIFF format (a single file which carries the metadata as TIFF Tags) or consist of two files, a plain TIFF file map.tif and an ASCII file map.tfw. A TFW, or world file, is a separate ASCII file containing the real-world transformation information used by the display software. World files can be created with any editor and also by GDAL. Make sure to get both files when not receiving GeoTIFF format. The TIFF format itself comes in several varieties, all of which are accepted by GRASS. The same LANDSAT-7 postprocessed scene we used above in ERDAS/Img format is also available as a GeoTIFF file (.tif extension). Use r.in.gdal just as you did with the ERDAS/Img LANDSAT-7 files:

     r.in.gdal -e in=<map.tif> out=<map>


5 Creating new GRASS locations from datasets

Both v.in.ogr and r.in.gdal have a 'location' parameter which can be used to generate a new GRASS location (including import of the dataset) from within an existing location. This greatly simplifies the procedure. Note that the dataset must include projection definitions. If lacking, ogr2ogr or gdal_translate can be used to assign the missing projection definition beforehand to the dataset ('-a_srs' parameter).

6 So many GIS formats....

To give you an overview, there are numerous formats supported by GRASS GIS.

Raster formats:

Vector formats:

Likewise, there are also export modules to write various formats (r.out.gdal and v.out.ogr).

7 Closing Your GRASS Session

In the command line terminal, enter:

     exit

to leave GRASS. The display manager must be closed by you; the monitor(s) are closed automatically.

So far you have seen a GRASS sample session with QGIS add-on and an import data session.


© 2005, GDF Hannover bR - Solutions for spatial data analysis and remote sensing