[Get Postscript version]

 

 

Introduction to GRASS GIS Software

by

Markus Neteler

 

 

Hannover - Germany

2. Edition, Feb. 1998

(minor HTML-corrections May 1998)


 

 

This text is based on "Introduction to GRASS GIS software" written by the author for

 

Institute of Remote Sensing

Anna University

Chennai (Madras) – India

 

within the scope of a

Ongoing GTZ project

 

in March 1997

 

 

© Markus Neteler, Hannover 1997-98

 

 

Author's address:

 

Markus Neteler

Institute of Physical Geography and Landscape Ecology

University of Hannover

Germany

 

email: neteler@geog.uni-hannover.de


Preface

 

The second edition of "Introduction to GRASS GIS Software" was necessary to update the document to the new developments in GRASS. In 1997 the GRASS Research Group was formed at Baylor University, Waco (Texas), U.S.A. which now maintaines the GRASS software package. Because of the need to keep GRASS available for the large user community worldwide, the GRASS Research Group has taken over support, research, and development from USA-CERL with the intent of keeping GRASS public-domain. The following project parts are established: The development of new GRASS versions (floating point GRASS is planned for summer 1998), new documentation, and also web-based information in internet.

 

This document was slightly changed and updated to new GRASS structures (mainly xy-locations). The authors hopes to give an easy introduction to this nice software package.

 

Markus Neteler

Hannover, 26. Feb. 1998

 


ATTENTION: This HTML-Document was converted automatically and contains some layout conversion errors. For your work it is recommended to make use of the postscript version also available here (go one page back).

Table of Contents

I. INTRODUCTION *

1. General Introduction *

1.1 System requirement *

1.2 General structure of GRASS *

1.3 Major modules in GRASS *

2. Data formats *

2.1 Raster data *

2.2 Vector data *

2.3 Point data *

3. Map output *

II. DATABASE CREATION *

1. The first steps *

1.1 Projections and coordinate systems *

1.2 What information are necessary ? *

2. Definition of a database *

1.1 Locations and mapsets *

2.2 The Projections and coordinate systems *

III. General file management commands *

1. Introduction *

2. Help system and file commands *

3. Deleting of mapsets and locations *

IV. Point Data Management *

1. Introduction to point data management *

1.1 Import and export of sites *

1.2 Display of the sites - displaycommands *

1.3 A few words about the GRASS monitors *

2. DTM analysis *

2.1 Topological analysis *

2.2 Interpolation of surfaces from spot heights *

2.3 Statistical report on sites files *

3. Triangulation *

3.1 Delaunay triangulation *

3.2 Thiessen polygons *

4. Conversions of sites to other formats *

4.1 Sites to raster format *

4.2 Sites to vector format *

V. VECTOR DATA MANAGEMENT *

1. Introduction to vector data management *

1.1 Import of vector data *

1.2 Export of vectordata *

2. Digitizing in GRASS *

2.1 Import of a scanned map *

2.2 Digitizing *

3. Conversion of vector layers to other formats *

3.1 Vector format to sites format *

3.2. Vector format to raster format *

4. Overlay and splitting of vectorlayers *

VI. RASTER DATA MANAGEMENT *

1. Introduction to raster data management *

1.1 Import and export of rasterdata *

2. Colortable modifications *

2.1 Assign a standard colortable *

2.2 Change the colortable interactively *

2.3 Display of colortable *

3. Display of raster maps in different scales *

4. Query raster cell contents and display of profiles *

5. Classification of raster maps *

6. Rescaling of raster maps *

7. Managing label information in raster maps *

8. Display of histograms and cell distributions *

9. Buffering *

10. Example: Creating a potential soil erosion map *

10.1 Generating the slope map *

10.2 Generating the vegetation cover map *

10.3 Generation the erodibility map *

10.4 Classification of the input maps *

10.5. Validation of the result *

11. Overview of the functions in r.mapcalc *

12. Overview of GRASS capabilities in watershed modelling *

12.1 Introduction *

12.2 Watershed calculation and creation *

12.3 DEM Calculations *

12.4 Rainfall data preparation *

12.5 Erosion and transportation models *

12.6 Runoff calculation *

12.7 Calculations on raster layers *

12.8 Automated boundary and line digitizing *

VII. IMAGE PROCESSING *

1. Introduction *

1.1 Definition of the xy-location for unrectified images *

1.2 Import of satellite images *

2. Rectification of satellite images and aerial photos *

2.1 Collect the image bands in a group *

2.2 Specifying the target location *

2.3 Setting the ground control points (GCPs) *

2.4 Verifying the quality of GCPs *

2.5 Minimum number of GCPs *

2.6 Transforming the images *

3. Image enhancements *

3.1 Contrast stretch *

3.2 Principal and canonical component analysis *

3.3 Fourier and inverse Fourier transformation *

3.4 Matrix filters *

4. Color composites *

5. Calculation of band ratios *

6. Introduction to satellite image classification *

6.1 Spectral pattern recognition *

6.2 Spatial pattern recognition *

7. Enhancement of image resolution using IHS/RGB transformation – image fusion *

VIII. CONCLUSION *

APPENDIX *

Appendix 1: Frequently asked questions and their answers *

Appendix 2: Script programming in GRASS *

Appendix 3: GRASS Command Overview *

GRASS display modules *

GRASS file management modules *

GRASS imagery modules *

GRASS data import/processing modules *

GRASS paint/print output modules *

GRASS raster modules *

GRASS sites management modules *

GRASS vector modules *

GRASS shell scripts *

Appendix 4: Linux Hardware compatibility list *

Appendix 5: Internet sites for GRASS *

Appendix 6: GRASS on CDROM *

References *


 

 

 

I. INTRODUCTION

 

1. General Introduction

 

The general purpose of using geographical information systems (GIS) is to collect, analyse, manipulate and display spatial data with their associated attributes. During the last decades a variety of GIS have been developed. Private companies as well as governmental, municipal organizations and universities are using these systems. Geographical information systems offer a simple and efficient way of spatial analysis.

 

A powerful GIS-package is the GRASS-Software. The name of GRASS-GIS is an abbreviation for "Geographic Resource Analysis Support System". It is a hybrid GIS-package - it manages raster, vector as well as point data and contains image processing modules. GRASS was released to public in the year 1989. It is a development of the U.S. Army Corps of Engineers, especially CERL (Construction Engineering Research Lab). Since 1997 it is maintained by "The GRASS Research Group" at Baylor University, Waco (Texas), U.S.A. Several people all over the world are also developing modules - discussions and exchanges are done mainly through Internet via email, WWW-servers and two newsgroups. Even extramodules are offered in the Internet, also the sources for the entire package in ftp-servers. They can be copied freely and are well documented. The GRASS package can be extended through selfwritten modules using the GRASS programming library (C language). Several institutes have produced such modules - for erosion predicting, watershed modelling, image classification, chemical solution transport etc.

 

1.1 System requirement

 

The GRASS sources can be compiled on all unix-platforms like SUN Solaris, SunOS, HP, SCO, SGI Indy, PC’s running LinuX, DEC Alpha etc. The needed capacity is generally at least 150 MB. For some platforms precompiled binaries are available in Internet.

Of special interest in the last years is the free UNIX-platform on PC’s, called "Linux". It is a full system with XWindows graphical user interface. If you want to use GRASS on your PC (486 or better), you can install this public domain unix operating system "Linux" on your PC. The Linux-system requires at least 120 MB (in an own partition beside DOS/Windows). The GRASS-binaries for Linux need only 40 MB. If you want to compile the package yourself some 150MB more space are necessary to store the sources. A three button mouse is also required.

The GRASS-binaries in all other unix-platforms need more space than in Linux, about 150MB. The GRASS source code can be compiled with the C compiler, some modules are written in Fortran 77 (Linux also offers free compilers, they are also available for other UNIX-platforms).

 

 

1.2 General structure of GRASS

 

The structure of the package can be described as followed:

GRASS Structure

 

 

 

Conversion between all dataformats are possible. The user can also overlay layers in different formats. Direct overlays in the same format can be made with point data resp. vector data. To overlay raster data several modules are available like adding, multiplying etc. In raster image processing color composite generating is there. Data can also be overlayed with weights. The data may be displayed in the graphical output window or stored either in imageformats or postscript maps.

 

 

1.3 Major modules in GRASS

Main topic

Modules

Raster analysis

Automatic rasterline and area to vector conversion

 

Buffering of line structures

 

Cell and profile dataquery

 

Colortable modifications

 

Conversion to vector and point data format

 

Correlation / covariance analysis

 

Expert system analysis

 

Interpolation for missing values

 

Neighbourhood matrix analysis

 

Raster overlay with or without weight

 

Reclassification of cell labels

 

Resampling (resolution)

 

Rescaling of cell values

 

Statistical cell analysis

 

Surface generation from vector lines

Vector analysis

Contour generation from rastersurface

 

Conversion to raster and point data format

 

Digitizing with board or on screen (scanned rasterimage) with mouse

 

Reclassification of vector labels

 

Superpositioning of vector layers

Point data analysis

Delaunay triangulation

 

Surface interpolation from spot heights

 

Thiessen polygons

 

Topographic analysis (curvature, slope, aspect)

Image processing

Canonial component analysis (CCA)

 

Color composite generation

 

Edge detection

 

Frequency filtering (Fourier, convolution matrices)

 

Fourier and inverse fourier transformation

 

Histogram stretching

 

IHS transformation to RGB

 

Image rectification (affine and polynomial transformations on raster and vector targets)

 

Ortho photo rectification

 

Principal component analysis (PCA)

 

Radiometric corrections (Fourier)

 

Resampling

 

Resolution enhancement (with RGB/IHS)

 

RGB to IHS transformation

 

Texture oriented classification (sequential maximum a posteriori classification)

 

Shape detection

 

Supervised classification (training areas, maximum likelyhood classification)

 

Unsupervised classification (minimum distance clustering, maximum likelyhood classification)

DTM-Analysis

Contour generation

 

Cost / path analysis

 

Slope / aspect analysis

 

Surface generation from spot heigths or contours

Screen displaying

3D surfaces

 

Color assignments

 

Histogram presentation

 

Map overlay

 

Point data maps

 

Raster maps

 

Vector maps

 

Zoom / unzoom -function

Map creation

PPM-image maps

 

Postscript maps

Extra modules

Database interfaces (Informix, Ingres, Postgres)

(several other modules are available)

Erosion modelling (AGNPS, ANSWERS)

 

Landscape structure analysis

 

Solution transport

 

Watershed analysis

 

 

2. Data formats

 

One of the main questions in a GIS is how to integrate the external data sources. This chapter describes the dataformats which can be imported into GRASS. If the data have a different format which is not supported by GRASS, then they can mostly be converted before importing. Several external programs for format conversions are available (especially for image formats). A famous program is "xv" which can be found in internet and compiled on any unix-platform. Another package are the "netpbm-tools" which are also stored in the Internet.

 

 

2.1 Raster data

 

GRASS accepts a variety of raster dataformats - most of them are equal to standard image formats.

 

These formats can be imported:

1. ASCII (X Y Z values, z value range from 2 E7 to -2 E7)

2. TIFF (8bit, cell value range 0..255, with none, LZW or PackBits compression)

3. GIF (8bit, cell value range 0..255, GIF87-encoding)

4. PPM (24bit, cell value range 0..16.7 mill.)

5. SUN Raster (8bit, cell value range 0..255)

6. NHAP (aerial photo imagery format)

7. BIL/BSQ (satellite imagery format)

8. LANDSAT TM, MSS (satellite imagery format)

9. SPOT (satellite imagery format)

 

Supported export formats are:

1. ASCII (X Y Z values, z value range from 2 E7 to -2 E7)

2. PPM (24bit, cell value range 24 bit)

3. PPM/3 (3*8bit, the image is splitted into R, G and B band)

4. TGA (24bit, cell value range 0..16.7 mill.)

5. TIFF (8bit, cell value range 0..255, with none, LZW or PackBits compression)

 

One disadvantage in GRASS version 4.1 and 4.2 is the limitation of raster cell values to be only whole numbers. If the user wants to work in raster with floating point numbers, he/she should multiply the cell values with 10, 100 etc. and divide later the final resulting rasterlayer by this number. Another way is to store the floating point values in the category file (see chapter VI.11 in "raster data management" for further explanations).

GRASS will get floating point capabilities soon in version 5.0, which is planned in summer 1998. It will be made available through GRASS Research Group. In point- and vectorformat are no limitations.

 

Please be aware of the fact that the size of rastercells is at least one (of your defined units). A rastercell size cannot have for example the resolution 0.1 (m, inch etc.). Normally the ground resolution is defined - satellite images have for example 30m (LANDSAT TM). So the resolution of one rastercell is defined as 30m in width and height (x and y extend). If you want to work in resolutions less than one meter, define your resolution in centimeter etc..

 

 

2.2 Vector data

 

GRASS vectors can be vectorpoints (not to be mixed with the GRASS point format) as well as line or polygon data. The exchange of these information is possible in several ways:

 

The accepted import formats for vector data are:

1. ASCII vectorformat

2. ARC/INFO (.arc, .line, .point and .textlabel files)

3. DXF

4. DXF3D

5. DLG (U.S. digital line graph format: optional format 3)

6. IDRISI

7. TIGER

 

To export vector data the following formats can be used:

1. ASCII vectorformat

2. ARC/INFO

3. DXF

4. IDRISI

5. MOSS

 

 

2.3 Point data

 

Point data, called "sites" in GRASS, are the third possibility of an dataformat. They are similar to vectorpoint data but stored internally in own tables. Conversion between vectorpoints and sites is possible. Point data may be spot heights or results of local measurements.

 

The point data can be imported in

- ASCII format (X Y Z values and a single word description for this point, delimiter may be

space, point or comma)

 

The Export is also possible in

- ASCII format (X Y Z values and a single word description for this point, delimiter may be

space, point or comma)

 

3. Map output

 

For map output GRASS offers a module for postscript maps and also maps in the image format PPM. Additionally there is an external mapcreation program "xmapgen". Both mapcreation programs are not very powerful, the definitions of the map layout have to be stored in a text file. Then the map is calculated by the GRASS module and the final result can be displayed with an imagery or postscript display program. So the user might be interested in using other external programs. For this purpose the layers can be exported and then imported into this external program.

 

 

II. DATABASE CREATION

 

1. The first steps

 

1.1 Projections and coordinate systems

 

The first step in working with a GIS is the definition of the database. In a GIS the information are stored with coordinates - therefore a coordinate system has to be specified. The system which is to choose depends on the purpose - for raw satellite images mostly simple x-y coordinates without units are taken, for "real" geographical data the geographic system (latitude, longitude) or a geodaetic projection like UTM or Gauss-Krueger. To optimize the projection from the geoid into a flat map the earth is approximated by an ellipsoid. GRASS offers on the one hand predefined projections as well as the geographic system and on the other hand the possibility to define a geodetic projection yourself. If this feature is used, the projection type, the ellipsoid and the datum for referencing the ellipsoid has to be specified. The supported ellipsoids in GRASS are: airy, australian, bessel, clark66, clark80, everest, grs67, grs80, hayford, hough, iau76, international, krassovsky, merit, mercury, modified airy, modified everest, modified merc, new international, SEasia, sphere, walbeck, wgs66, wgs72 and wgs84. Defining an own projection can be done in the following systems: latitude-longitude, UTM, State Plane, Albers equal area, Lambert conformal conic, Mercator and in transverse Mercator (for Gauss-Krueger).

 

 

1.2 What information are necessary ?

 

To specify your database the following information are necessary:

· the coordinate system for the database (plain or with projection and ellipsoid)

· the minimum and maximum coordinates of the area of interest

· the ground resolution

 

Before the database can be created all these information have to be collected.

 

 

2. Definition of a database

 

1.1 Locations and mapsets

 

The first step in now to start the GRASS-package (the $ symbol is the unix prompt):

$ grass

 

In the first screen the name of the "location", the "mapset" and the GRASS-directory has to be specified. This GRASS directory must be created before using GRASS for the first time. Here are all data stored. Normally the user does not have to modify any GRASS-datafiles in this directory.

 

 

The "location" is the entire area. The "mapset" is the active used part which can be smaller or as big

as the location. Several mapsets can be defined within one location. The first screen displays:

After entering the names and the database-directory this screen can be left with <ESC>. Now the required definitions for the project area (location) are requested. The names given in the first screen are always stored for the next start of GRASS.

Now the coordinate system has to be chosen. As descibed above, the plain xy-system, several projections and the geographical latitude-longitude system are available.

 

The procedure in each particular projection is as following:

 

 

 

2.2 The Projections and coordinate systems

 

(0) X-Y-system

Choosing the xy-system (for imagery and other unreferenced raster data) GRASS expects to

· enter a one line description and

· to define the default region (= location).

The origin is in the lower left corner. The south and east value will be calculated from the image size. The resolution is always 1 in xy-system.

 

Example:

Image size: 800 * 512

Definition of the default region:

 

DEFINE THE DEFAULT REGION

 

======= DEFAULT REGION ========

| NORTH EDGE: 512 |

| |

WEST EDGE | | EAST EDGE

0 | | 800

| SOUTH EDGE: 0 |

===============================

 

PROJECTION: 0 (xy) ZONE: 0

 

GRID RESOLUTION

East-West: 1_________

North-South: 1_________

 

AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE

(OR <Ctrl-C> TO CANCEL)

 

 

 

 

(1) UTM

Using the UTM-projection the following information are required:

· enter zone (e.g. 30)

· enter a one line description

· define the default region (= location): specify your UTM-coordinates

· choose the ellipsoid (see list above or enter "list" here).

 

(2) State Plane

This projection is an U.S. specific projection.

 

(3) Latitude-Longitude

This system is a geographical reference. Here the user has to enter

· enter a one line description

· define the default region (= location): specify the latitude and longitude in decimal degrees.

 

Example: Madras (all values have to be entered in decimal degrees)

 

DEFINE THE DEFAULT REGION

 

======= DEFAULT REGION ========

| NORTH EDGE: 13.0 |

| |

WEST EDGE | | EAST EDGE

80.1 | | 81.0

| SOUTH EDGE: 12.0 |

===============================

 

PROJECTION: 3(Lat/Long) ZONE: 0

 

GRID RESOLUTION

East-West: 0.01______

North-South: 0.01______

 

AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE

(OR <Ctrl-C> TO CANCEL)

 

 

Result (in degrees, minutes, seconds):

 

projection: 3 (Latitude-Longitude)

zone: 0

north: 13N

south: 12N

east: 81E

west: 80E

e-w res: 0:00:36

n-s res: 0:00:36

 

total rows: 100

total cols: 100

total cells: 10,000

 

(99) Other projection - own definitions

 

With this option an own projection can be defined. For example the Gauss-Krueger-projection, which is very common in Europe, can be specified. It is a transverse mercator projection. What are the steps?

 

First "Other" (99) will be chosen in the projection menu. Then you

 

· enter a one line description

· define the default region (= location): the coordinates depending on the projection

· specify the projection name

· choose the ellipsoid (see list above or enter "list")

· specify the datum (reference of the ellipsoid)

· enter scaling and units.

 

Here is an example for the region definition screen (with Gauss-Krueger coordinates):

 

 

After the definition of the location the first screen appears again. The names and the GRASS-database directory may be unchanged - the screen has to be left again with <ESC>. Now the mapset is created. The coordinates for your mapset will be set to the location coordinates in the beginning. Further on they can be changed manually or by using the mouse-zoom-module.

The idea of defining several mapsets in one location is to have a clear datastructure. For example several quarters in a city can be managed. Normally the data of other mapsets in a particular location are unvisible to the active mapset, but they can be accessed through a special access-module. But it is untypically for a GIS, that data for different areas are identical.

 

With returning to the standard unix-prompt the GRASS-package is activated. Beside all unix-programs the GRASS-modules (more than 300) are useable now. Very important is to leave the package properly after finishing work. Otherwise the datastructure may be damaged. To leave the GRASS software enter the command:

$ exit

 

GRASS asks now for the saving of the data. The default is "yes". Here (and also in the package) single files can be deleted.

 

 

 

 

 

 

 

III. General file management commands

 

1. Introduction

 

Before starting with single command-descriptions the general command structure shall be explained. The command-structure is very easy to understand - the topic of the command determines the first letter of the GRASS module followed by a dot. The next word defines the subtopic, some command also have a subsubtopic. The following groups can be found:

 

d.*

- display commands for graphical screen output

g.*

- general file management commands

i.*

- image processing commands

r.*

- raster processing commands

v.*

- vector processing commands

s.*

- site processing commands (point data)

m.*

- miscellaneous commands

p.* / ps.*

- map creation commands

...

- unix scripts

 

Some examples for GRASS-commands: The name for displaying a image histogram becomes "d.histogram", the satellite image rectification module is named as "i.rectify", renaming a file can be done with "g.rename". For a single line description of more than 250 commands, please refer the Appendix 3: "GRASS Command overview" in this paper.

 

GRASS stores its data in an own directory, called the "GRASS database". Vector data are stored in a specific binary format, site data (point data) in ASCII lists, raster (imagery) data also have a specific compressed binary format. Access to the "outside" world is given through several modules (refer chapter I.2 in this document for the exchange formats). Normally the user should not affect files in the GRASS database. The management is done by the modules themself, to say, the files are physically "invisible" for the user.

 

 

2. Help system and file commands

 

Online help is available through display- and printable postscript-documents, local WWW-pages or with using the GRASS module:

$ g.manual

 

If this command is directly entered, a command list can be shown. The other way is to give a GRASS command name as parameter:

$ g.manual i.rectify

 

If there is no manual-page available, a short description can be displayed with the "help" parameter for the module:

$ i.rectify help

 

A better overview is given by the WWW-manpages. Free programs like mosaic, netscape or lynx can display them. These programs can be easily installed in unix. Open in such a program the main WWW-file "grass.html" as local file. This file can be found in the grass directory, subdirectory ./html (for example /usr/local/grass4.2/html/grass.html).

 

The printable documentation (postscript files and textfiles) is stored in the ./documentation directory (e.g. /usr/local/grass4.2/documentation/). For previewing and printing of postscript files use

$ ghostview

and $ gs

 

All commands can be used interactively (enter only the command name), then the module asks for filenames etc. Or all required information can be given as parameter, the "help" parameter shows the syntax. This is important for using GRASS commands in unix-scripts.

 

Examples:

Purpose

Command

Copying of files

$ g.copy

Deleting

$ g.remove

List filenames

$ g.list <datatype>

Renaming

$ g.rename

 

 

3. Deleting of mapsets and locations

Sometimes it might be interesting to remove complete mapsets or even locations. A mapset can be deleted after giving the "exit" command to leave GRASS. Then the user is asked for removing single files or the entire mapset.

Locations can only be deleted outside of GRASS. Leave GRASS and use the unix "rm" command (or "rm -rf" to avoid to be questioned for every file).

Please use for file-deleting in the GRASS database only the "g.remove" command, otherwise the database structure may be disturbed.

 

 

IV. Point Data Management

 

1. Introduction to point data management

 

In environmental studies are very often data only for particular stations or locations available. That could be for example spot heights (elevation data), taken from a toposheet, drill hole data or measured outside or rainfall data, measured by a climatic station. Several modules are offered by GRASS to analyse and convert these data. Point data are called "sites" in GRASS. In opposite to vectorpoints stored in vectorformat this is an own format. Internally an ASCII table is created in the GRASS database.

 

 

1.1 Import and export of sites

 

The import and export can only be arranged in ASCII format. This format is the most common format and available in every spreadsheet program, if the original data are stored there. To create this file export the sites in your spreadsheet program in the following ASCII structure (the description is optionally, a header is not necessary):

 

Generally: Example:

X-value1 Y-value1 Z-value1 desc1 3570321 5776988 102.4 Adyar

X-value2 Y-value2 Z-value2 desc2 3571987.3 5776876.4 110 Airport

X-value3 Y-value3 Z-value3 desc3 3574987 5777987.5 132.2 TTKRoad

...

 

Are the point data not stored in a spreadsheet program use a simple textedior to create this ASCII-file. The first two values (x and y) may be the coordinates while the z-value is the measured value like a spot height. But don't give any units here. The x-value is the easting, the y-value the northing coordinate. Allowed field separators are "space", "tab" and a character to be specified. "Space" is the default field separator. A description can be any text without spaces (use for space the underline character) but is only optional. This description is called "label" in GRASS.

 

Import

The importmodule is started with:

$ s.in.ascii

 

As usual the module can be used either interactively (menudriven) or non-interactively by giving parameters. The best way is to store the import-ASCII-file in the active directory. First the "sites name" - the name for the file in the GRASS database has to be given, then the name of the ASCII file containing the sites (exportfile from worksheet etc.). After specifying the field separator the sites are imported. Are the data imported from a DOS-textfile, the DOS-ASCII has to be converted into unix-ASCII.

 

Use the program

$ dos2unix file.asc

for this conversion. If this program is not available in your unix ask your system administrator (it might have another name).

 

The user can check for the existance of the file in the GRASS database with:

$ g.list sites

This command gives a list of all available site-files in the active mapset.

 

Export

The export module works similar, but the output has to be redirected into a file (otherwise screen output is given):

$ s.out.ascii > file.asc

First the sitesname ("list" shows all sites in this mapset), then the field separator has to be given. After that the module allows to choose if either all sites in he location or only the sites of the mapset shall be exported. The last question concerns the output of site descriptions.

The resulting file is stored in the actual directory.

 

 

1.2 Display of the sites - displaycommands

 

What is the result? To get a graphical output on the screen first the graphical outputscreen has to be started. This window is called the "GRASS monitor". It is possible to use up to eight "monitors", named from "x0" to "x7".

Before starting the window be aware that neighter a graphical WWW-program nor the image-conversion program "xv" is running. Otherwise the management of the colortable will run into conflict. These critical programs can be started after starting the GRASS monitor. Use the module either interactively with

$ d.mon

or commandline driven:

$ d.mon start=x0 or short

$ d.mon x0

 

To close a GRASS monitor enter:

$ d.mon stop=x0

 

Now you want to display the sites. Sites can either be displayed with or without description (text label of each site):

$ d.sites (each site is marked with a "x")

$ d.site.labels (each label is given without "x")

 

If you don't want to change any options in these modules just give the site-filename as parameter.

Shall both be displayed ("x" and description) call both modules.

 

To erase the screen enter:

$ d.erase

This command is very important: after changing the active region (change of coordinates) always this command has to follow. Otherwise coordinates in the GRASS monitor are not set properly.

 

 

1.3 A few words about the GRASS monitors

 

The monitor is somehow sensitive: You should take care not to change the monitorsize with the mou se (use environment settings instead) and to close it after work with the "d.mon stop=x0" command. If you only close the window from the unix-windowmenu GRASS cannot not realize that the window is closed. It will remain blocked for further use untill you enter GRASS again and stop it.

Solution for the first problem: Was the size accidentially adjusted, the "d.erase"- module might clean the monitor. Otherwise stop and start it again.

Did you forget to close the monitor and have already left GRASS, start GRASS again and select the monitor by:

$ d.mon select=x0

Then you can stop it.

Every user in the unix-system can use one or more monitors. But one monitor can only be used once at time.

If you are switching the location to another location and both have different projections the monitor always has to be closed before exiting GRASS.

 

 

 

 

2. DTM analysis

The new sites information layer can be taken for analysis purposes. First the analysis of elevation data like spot heights will be discussed, later of hydrological data. Finally the conversion into other dataformat is described.

 

 

2.1 Topological analysis

 

The structure of the ASCII-importfile with spot heights is usually like this:

 

Easting Northing Heightvalue

Easting Northing Heightvalue

...

 

Due to the limitation of standard GRASS in the rasterformat, that only non-floatingpoint values as z-values (cell values) can be used, you should contemplate to convert these heights to whole numbers. This can be done by multiplying the heightvalues with powers of 10. This procedure is only of interest, if you want to convert these sites later into a rasterformat layer.

Unix offers a simple method to multiply the third column (or other columns) with 10, 100 or other numbers. Enter therefore:

$ awk '{print $1, $2, $3*10}' file.asc > newfile.asc

 

The first and the second column $1 and $2 are unchanged, the third column $3 is multiplied with 10 and everything stored in a new file. "Awk" is a standard unix program. Remaining decimals will be rounded in the conversion process to rasterformat.

 

The imported spot heights can be used for several topographical calculations:

· slope, aspect

· profile curvature (measured in the direction of steepest slope)

· tangential curvature (measured in the direction of a tangent to contour line)

· mean curvature

With an existing rastermap (rasterlayers are described later) it is possible to mask areas of interest and non-interest. The corresponding GRASS module is:

$ s.surf.tps

 

It stores the results in only in rasterlayers and interpolation is done during the calculations. These rastermaps are like surfacemaps.

 

In this module several options can be set for the calculation:

 

· dmin1: Set minimum distance between points. Default value is set to 0.5 grid cell size of the resolution defined during the definition of the database.

· zmult: Convert z-values using conversion factor. Default value is 1 (use this option instead of awk, if you like).

· tension: Set tension. Default value is 40, appropriate for smooth surfaces.

· smooth: Set smoothing parameter. Default value is 0, no smoothing is performed.

· segmax: Set max number of points per segment. Default value is 40.

· npmin: Set min number of points for interpolation. Default value is 150, for data with heterogeneous spatial distribution higher value is suggested.

 

But mostly you will accept the default values. The algorithm is spline interpolation with tension.

 

Display of the results

 

Because the interpolation results from sites are mostly in rasterformat, here a small outlook to the display of raster images is given. This topic is described more specific later on. Before displaying the results, the GRASS monitor (e.g. x0) has to be started as described above.

 

The command to display rasterimages is:

$ d.rast rasterfile

If you want to look up the filenames of the calculated rastermaps enter:

$ g.list rast

 

You see the raster layers calculated above and can display them using the "d.rast" command. Now it might be interesting to have a closer look to some particular areas in the active mapset. The command for zooming in a rastermap is called:

$ d.rast.zoom

 

After entering this command move the mouse to the GRASS monitor, click a desired corner of the area of interest. Moving the mouse opens a window, the right button accepts the chosen portion.

Unfortunately there is not yet any mouseoriented "zooming-out" tool. The "d.rast.zoom" offers to unzoom to the last zoom step. Otherwise the mapset has to be set to its defaults (the maximum extent), after that portions can be zoomed again. To set the mapset to its default coordinates enter:

$ g.region -d

$ d.erase

 

Always the "d.erase" has to follow to transmit the new coordinates to the GRASS monitor. Otherwise you either see the same resolution and coordinates as before or nothing any more.

The "g.region" module allows, if used interactively, to change the coordinates manually.

 

 

2.2 Interpolation of surfaces from spot heights

 

GRASS offers three module for the surface interpolation. This surface is stored in the raster format. Important is to know the number of spot heights, otherwise the interpolation may not be done properly. So first you count the number of given points in the ASCII-file containing the spot heights. For this you use the standard unix command "wc" (word count, which also counts lines with -l option):

$ wc -l spotheights.asc

 

As result you get the number of given points. With this information the interpolation can be started:

$ s.surf.idw in=spotheights out=elevation npoints=<number>

 

The input is the sitesfilename (GRASS name, can be looked up with "g.list sites"), <number> the above counted number of points and output the new rastersurface. With:

$ d.rast elevation

 

you can display the DEM on the screen.

 

If you want to use the "Kriging" algorithm, call the module

$ s.surf.krig

 

This module is an example for external extensions of GRASS, it was developed by an U.S. university. Information about Kriging can be found in the help-pages of SURFER(TM). Without proper parameters it will not produce any results.

 

Then the above described module:

$ s.surf.tps

calculates a DEM from given spot heights (splines with tension algorithm).

 

2.3 Statistical report on sites files

 

To get some information on the point data reports can be prepared with the module:

$ s.menu

 

This module is menudriven - you can easily get some statistical information.

 

3. Triangulation

The standard GRASS distribution offers two modules for triangulation. In GRASS 4.2.1 two new packages can be found - the v.geom- and the s.geom-package, where some improvements and additions have been done. Here the description for the standard modules follows.

 

3.1 Delaunay triangulation

 

To perform a convex hull shape triangulation, the module

$ s.delaunay

can be used. The result is a vector layer which can be displayed with

$ d.vect

To get a list of all available vectorlayers, take the module

$ g.list vect

 

3.2 Thiessen polygons

 

To calculate Thiessen polygons in hydrological analysis of precipitation data there are two posibilities. The result can be stored in two different formats, either in vector areas (polygons) or in raster format. The choice depends on the further work. The input file is as usual a ASCII-file (see above) with Easting and Northing coordinates of each climate station and the rainfall amount as third parameter.

 

3.2.1 Output in vector format

The module

$ s.voronoi

creates Thiessen polygons in a vector layer.

 

3.2.2 Output in raster format

To store the calculated polygons in the raster format, use

$ s.surf.idw in=rainfall out=thiessen npoints=1

 

Important is to set the number of interpolation points (npoints) to "1".

 

 

4. Conversions of sites to other formats

 

4.1 Sites to raster format

 

This type of conversion does not perform a interpolation. The sites are directly converted into the rasterlayer without correction of coordinates. The non-occupied cell values are "0".

$ s.to.rast

 

To move the points onto a given vectorgrid (create with "v.mkgrids") you can use the polishing-module:

$ s.medp

All sites are moved to the next vectornode of the vectorgrid. The result is a new sitesmap.

 

4.2 Sites to vector format

 

To convert sites into the vectorformat use the module:

$ s.to.vect

The sites are stored as vectorpoints.

 

The resulting vector layer can be displayed with

$ d.vect

 

 

V. VECTOR DATA MANAGEMENT

 

1. Introduction to vector data management

 

The vector datatype is based on shape oriented structures. It describes only the outline of structures. These structures may be linear structures like roads or streams or areal structures like lakes or fields. For example: You have cadastral data like ground plans of houses, so you are not interested what happens inside these rectangles. The required datatype would be vector - only the outline of the shape is of interest. Because of this less capacity is needed to store the information in the computer: The starting and the ending coordinates, the type of the structure (line, polygon etc.) and the attribute.

 

1.1 Import of vector data

 

ARC/INFO format

Mainly you will have two different data sources: Maps on paper or vectormaps already prepared in an other GIS. The first topic will be discussed later on, here first follows how to import vectorfiles. Because the ARC/INFO vectorformat is most common only this topic is discussed here. Many GIS offer an export into this format which can be read in into GRASS.

 

The following chapter explains how to export the data from ARC/INFO itself. There are slight differences between the PC-based version of ARC/INFO and the UNIX-based version.

 

1.1.1 Export out of PC-ARC/INFO

The coverage-type can be "polygon" or line - the "describe" command helps you in ARC/INFO to find out. The precision must be "single precision". To export the data, you open your coverage in ARC/INFO and use the "ungen" command :

 

arc> ungen <datatype> <coveragename> <exportfilename>

 

The data are organized in two different structures:

· the line data (with start and ending coordinates)

· the label points (point coordinates for the label of each line) - only in polygon coverages

· the labels itself

All information have to be stored into different files. So you first export the linevectors resp. the polygons from the coverage (either a) or b), it depends on your ARC/INFO coverage type):

 

a) Type: line coverage

Export the linevectors into the lines-vectorfile (example: coverage name might be topo12):

arc> ungen line topo12 topo12.lin

 

b) Type: polygon coverage

Export the polygonsvectors into the polygon-vectorfile (example: coverage name might be topo12):

arc> ungen poly topo12 topo12.pol

 

Now the labelpoint data will follow (for polygon type):

arc> ungen points topo12 topo12.lab

 

The linked attributes have to be exported from the database used in ARC/INFO. Normally this is dBase in the PC-version. Store this table (pat.dbf) into a ASCII-textfile. The header has not to be removed from this textlabel file. Then you can continue with the import into GRASS.

 

1.1.2 Export out of UNIX-ARC/INFO

The export from points, lines and polygons is identical to the PC version. Only the database management differs, UNIX-ARC/INFO uses the INFO database.

After the export of the line or polygon coverage you have to start the INFO database program

within ARC/INFO:

arc> info

Now caps-letters are required.

The required username is "arc". Please give the following commands now:

ENTER COMMAND> SELECT <COVERAGE>.PAT

ENTER COMMAND> OUTPUT ../<coverage>.txt

ENTER COMMAND> LIST PRINT

ENTER COMMAND> Q STOP

 

Example:

ENTER COMMAND> SELECT TOPO12.PAT

ENTER COMMAND> OUTPUT ../topo12.txt

ENTER COMMAND> LIST PRINT

ENTER COMMAND> Q STOP

 

The result is the ASCII-file topo12.txt. Its structure is:

$RECNO AREA PERIMETER TOPO12# TOPO12-ID TOPO12-NAME

1 -2.30228E+0 19399.848 1 0 forest

2 81079.875 1678.826 2 1 wetland

3 955952.500 10229.637 3 2 lake

Now you can leave ARC/INFO. Then you can continue with the import into GRASS.

 

1.1.3 Import into GRASS

The three exported files have to be stored into the GRASS database manually (one of the few moments, you are allowed to do that...). Go into the directory grass_data which exists in your home directory:

$ cd grass_data

 

Then you change into the subdirectory with the name of your location, and within this directory again into your mapset (again a subdirectory). Is your location for example chennai and your mapset adyar that would be

$ cd chennai

$ cd adyar

 

In this directory there you create a direcory arc.

$ mkdir arc

 

Into this directory you copy ("cp"-command) all three export-files.

Then you can go back to you home directory.

 

Now the import can begin:

$ v.in.arc

 

Question:

Line-coverage in ARC

polygon-coverage in ARC

The first parameter is the name for the new vectorlayer in GRASS

topo12

topo12

The next parameter is the coverage "type" in ARC/INFO:

line

polygon

With polygon-type it is asked for a neatline:

------------ (not required)

no

The next parameter is the "linevector"-file from ARC/INFO:

topo12.lin

topo12.pol

Then the "labelpoints" will be specified:

------------ (not required)

topo12.lab (if not available,

press return)

The "label texts" are the attributes (only read in when labelpoints there):

topo12.txt

topo12.txt

 

If labelpoints are there the import module shows the beginning of this label file (the first three lines).

 

It may (!) look like this (so be careful), depending on the ARC-version:

$RECNO AREA PERIMETER TOPO12# TOPO12-ID TOPO12-NAME

1 -2.30228E+0 19399.848 1 0 forest

2 81079.875 1678.826 2 1 wetland

3 955952.500 10229.637 3 2 lake

The import-module asks now for the number of the ID-column. That will be the column with continous numbers (here: 4). The CAT-column (category value) is the next following column-number (5), the ATTRIBUTE the number of first text column.

The import will be completed then. After this module the creation of the support files have to follow:

$ v.support map=topo12

 

Here you specify the new GRASS vectorlayer as filename. The idea of this module is to reorganize the vectorlayer properly.

 

After the starting of a GRASS monitor the imported layer can be seen with

$ d.vect topo12

 

 

1.2 Export of vectordata

 

1.2.1 ARC/INFO format

GRASS also supports the export into the ARC/INFO-format. You start the module

$ v.out.arc

It asks for the coverage type (line or polygon), the GRASS vectorlayer and the prefix to be given for the file extensions (.lin.,.lab,.txt). You can specify here the same name like the GRASS vectorlayer.

You should export both coverage types from the same file, only in this case line as well as polygon structures are exported. So this module has to be run twice.

 

Attention: The output is not stored in the home directory, but again (like above) in the GRASS database. Change the directory to find the files:

$ cd grass_data/<location>/<mapset>/arc/

Example:

$ cd grass_data/chennai/adyar/arc/

 

1.2.2 Export into DXF-format

For the use of GRASS-vectorlayers in CARIS it is only possible to export the files into the DXF-format because CARIS does not accept ARC/INFO-format. First the vectorlayer has to be cleaned and then converted from the internal binary format into the internal ASCII format. Choose the module:

$ v.support map=vectorlayer

$ v.out.ascii

 

It asks for the existing binary vectorlayer and then for the name for the new ASCII-layer. Give the same name. To export the file use:

$ v.out.dxf

 

The module asks for the ASCII-layer name and the new DXF-name. The file is created and can be taken from the home-directory.

 

The import of DXF into GRASS is actually a problem with newer software because of changes in the DXF-command structure. But the module could be updated because the source code is available.

 

 

2. Digitizing in GRASS

 

Digitizing is used to transfer information from papermaps like toposheets or thematic maps into a GIS. GRASS provides support for digitizer board as well as mouse digitizing on the screen (in the GRASS monitor). The second way is less costly, "only" a scanner is required to scan the map on paper. Then this scanned image can be imported as rasterlayer (xy-system) and rectified into the location with geographic coodinates or projection. For this purpose you will use the i.rectify-command, assign geographic coordinates to the four corners of the image and then transform it (affine transformation). The result is a geocoded map in the location. This is discussed later on in chapter VII "Image Processing". This scanned map can be used as "backdrop-map" in the digitizing module. With the mouse on-screen digitizing (with zooming and panning) is possible.

 

The configuration of a digitizing board is somehow difficult (as usual in GIS): The configuration file has to be set properly and then the driver to be compiled (C-compiler). There are several precompiled drivers available. But here only the more easy way of using scanned maps will be discussed.

 

2.1 Import of a scanned map

 

The scanned map has to be stored in a standard image format. The best choice is, because the map will be in colors or greyscale (both a 8bit format in computers), to store it in in the following way:

 

1. colorimage: GIF (8bit = GIF87), SUN Raster (8bit), TIFF (8bit with none, LZW or Packbit compression), PPM (24bit)

2. greyscale image: TIFF (8bit with none, LZW or Packbit compression) or GIF (8bit = GIF87)

 

Every scanner software will support one of these image formats. The file has to be stored in the home directory on the unix machine. Because this image being without georeference, it has to be transformed. See the chapter VII "Image processing" later on, in what way the xy-location has to be defined and the affine transformation to be performed.

 

It shall be suggested now that the image is already in a database with projection (UTM, Lat./Long. etc.). With

$ d.rast mapname

you can, as usual, display the map in the GRASS monitor.

 

2.2 Digitizing

Now the digitizing module can be started:

$ v.digit

Please do not change the size of the terminal window below the size of 80x25 (simply take the original size). Otherwise the menusystem from v.digit cannot be opened.

The first choice is the digitizer, if you want to digitize using the mouse, choose "none". Then the module asks for the name of a vectormap layer (existing or new name).

 

After that a new screen opens:

 

Here you can fill out the first 5 lines (not necessary). Important is to set the "Map's Scale" properly. For the mouse digitizer choose:

Map's scale: 1:1

If you are using a digitizing board, specify here the map scale of the papermap. The coordinates are taken from the region-setting. If you are using a digitizing board, the referencing follows. After confirmation of the next message the following screen, the digitizing menu, appears:

 

With pressing the first letters (In caps! Please look careful for these first letters) you enter the me-nues. In "Digitizing" you can digitize, "Edit" allows later on corrections, "Label" allows labeling (assigning attibutes to the vectors), also automated contour labeling. "Customize" has the menu to display the scanned map (choose "Backdrop cell map" and give the name of this map). "Zoom" is also important, you can magnify particular regions or use the "panning" function (that is shifting the middle of the area, useful to "move around" on the map). If a "Buttons choice" message appears, always the mouse has to be used in the GRASS monitor.

This module is self explaining and has a help function. If you leave "v.digit" the map will be saved.

For more explanation please refer the "GRASS tutorial: Digitizing" (see References).

 

3. Conversion of vector layers to other formats

 

Before using the conversion routines you should always use the "clean-up"-module:

$ v.support map=vectorlayer

 

3.1 Vector format to sites format

The conversion to the sites format (if you digitize spot heights with height information as label) is done with:

$ v.to.sites

 

3.2. Vector format to raster format

The conversion to rasterlines (from lines) and rasterareas (from polygons) is performed with:

$ v.to.rast

 

4. Overlay and splitting of vectorlayers

 

Several vectorlayer can be overlayed into one layer with the module:

$ v.patch

To split vectorlayers use the module

$ v.cutter

After this

$ v.spag -i

has to be run. This cleans unused nodes and double lines from the layer. Please refer the manpages (g.manual or WWW) for further information.

 

 

VI. RASTER DATA MANAGEMENT

 

1. Introduction to raster data management

 

The use of raster data offers a nearly "never ending" variety of possibilities to calculate and derive maps. The input may be toposheets, thematic maps, aerial photos or satellite images. From these data cellwise or matrix-oriented calculations can be carried out to create new thematic maps. Later on in this training also image enhancement and the derivation of thematic maps from satellite images will be discussed. Very interesting is the feature of raster maps that the neighbourhood influence can be calculated: This allows to create transportation models (for soil erosion, water movement, pesticide movement etc.).

 

Two different facts have to be distinguished in raster data: On the one hand there are the cell values, the "z-values" with coordinates. On the other hand a colortable can be assigned to these cell-values depending on the users purpose. Both is possible: Either each cell has its own color for the display or color is assigned groupwise to the cell-values, they are "classified" in this case. About this you
should consider carefully, because a change in colortable does not affect the cell values. That is important for the calculations further on.

In scanned maps the colors of the original map determine the cell values, they are the same. But after the import into a GIS like GRASS the user can either assign other colors to the map without changing the cell values or change the colors of the map (without having a colortable) by changing the cell-values. In this case the system itself assigns the colors.

 

 

1.1 Import and export of rasterdata

 

To import raster data like scanned maps, satellite images, scanned airphotos etc. several import facilities are offered. The choice of the imageformat depends on the source you want to import.

 

1.1.1 Scanned maps (greyscale or color)

If you scan a map you have normally 256 colors or greyscales (both 8bit). The scanning software offers several image formats, you can choose here the GIF format (GIF87). GIF89 is not (yet) supported, because it is a 24bit format.

 

To import a scanned image, store it into the working directory. Because an image is not georeferenced there are two choices:

1. The images fits into the entire location or into a part of it.

2. The image has to be rectified.

We discuss only the first possibility here, the second will be discussed in the chaper "Image processing" later on.

 

For the first choice you must know the boundary coordinates of the image map and its ground resolution (for example 30m). Ground resolution means the extent each raster cell has. This can be calculated from the resolution chosen in the scanning process (dpi = dot per inch = lines per inch).

Example:

Scanner resolution: 300dpi. Scale of the map: 1:100.000

One centimeter is equal to 1000m.

300dpi = 300 lines per inch = 300 lines/2.54cm = 118.11 lines/cm

Per centimeter the ratio is: 1000m/118.11 lines = 8.47m/line

The raster cells are squares, therefore the cell resolution is 8.46m x 8.46 m.

 

Now you set the coordinates and the calculated resolution in GRASS:

$ g.region

The menue 1 allows: "Modify current region directly". Type in here the coordinates of the image and the ground resolution.

 

After leaving this module you must use

$ d.erase

to send the new coordinates to the GRASS monitor.

 

Then you can import the image:

$ r.in.gif

The first filename is the GIF-file stored in your working directory. The second name is the new rastername to be used in GRASS. Optional a title can be specified. For the "verbose" mode say "yes" - you get information about the progress of import or errormessages, if the imageformat does not fit.

 

For TIFF you type in:

$ r.in.tiff

The use is similar to GIF import.

 

After each import the module

$ r.support

has to be run interactively. Note: It is the similar to the situation when you import vectorlayers and use "v.support" afterwards on this vectorlayer.

 

GRASS allows you now to adjust the rasterlayer coordinates, because it cannot guess the proper coordinates itself. So specify as filename the name of the just imported rasterlayer.

· "Edit the header?": y

· "Please enter the following information...": <ESC> (leave this page unchanged!)

· Now the coordinates of the image can be specified. Give here the boundary coordinates of your image as you have done in the g.region module.

 

With <ESC> you leave this screen after entering the rasterimage coordinates properly.

· "Update the stats...": y

· "Edit category file": n (for the future: here you can change textlabels assigned to cell values)

· "Create/update colortable?": n

· "Edit the history file...?": n

 

The file is imported properly now. You can display the imported image with

$ d.rast

 

 

1.1.2 Rasterdata with range from 0 to +16.7 million (24bit)

The second possibility is to store data in PPM-image format. The procedure is the same as using the GIF import module. For PPM you use

$ r.in.ppm

 

If you want to import images from three channels (RGB), then you can convert each of them to 8bit-PPM and import it with

$ r.in.ppm3

 

All the image format conversions can be done with the program

$ xv

which belongs to the standard LinuX distribution (shareware, can be compiled on every unix-platform). You load the image (load button) and save it again, in the save menu you choose your image format.

 

 

1.1.3 ASCII-Data (positive and negative values)

If you have data with positive and negative range (e.g. bathymetric data) you cannot use image formats because they don't support negative values. This type of data can be imported in a ASCII table.

The structure is the following:

 

north: 4928000

south: 4914000

east: 609000

west: 590000

rows: 700

cols: 950

28 28 28 28 28 28 28 52 52 52 52 51 51 51 51 51 51 51 51 51 51 51 51 52 52

52 52 52 52 52 52 52 52 51 51 51 51 51 51 51 51 51 51 51 26 26 26 26 26 26

47 47 47 47 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 44 44

44 44 44 44 44 44 44 29 29 29 29 29 29 35 35 35 35 35 35 35 35 35 35 35 35

35 29 29 29 29 29 29 29 29 29 29 29 54 54 54 54 54 54 54 50 50 50 50 50 50

50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50 50

...

 

The header has to be added to your ASCII values. The number of columns and rown depends on the distance between the east-west and north-south boundaries and the resolution.

Then the rastercell values follow: Sorted from north to south and west to east. That means, the data have to be exported into the ASCII-format linewise from left to right and from the upper boundary down to the lower boundary. After each ending of the line, there is for the next line a jump back to the left boundary.

Set the region properly (resolution!) with g.region. The module's name for ASCII import is:

$ r.in.ascii

After the import

$ r.support

should follow to adjust the coordinates from the rasterlayer.

Then it can be displayed with

$ d.rast

 

1.1.4 Export

For positive values up to 255 (export in 8bit format) you can use

$ r.out.tiff

After specifying the file names you can choose if you want the file compressed.

 

Also the export can be performed in the 24bit image formats PPM and TARGA (positive values up to 16.7 million):

$ r.out.ppm and

$ r.out.tga

or also splitted into the three basic colors (result are three RGB PPM-files):

$ r.out.ppm3

With the "xv" program these image formats can be changed to others, also to 8bit GIF.

 

If you have negative and positive cell values, the ASCII format can be used for exporting:

$ r.out.ascii > textfile.asc

Here the output has to be redirected into a file.

 

 

2. Colortable modifications

 

As described above, the colortable is assigned to the cell values. These values are also called "category values". After importing a rasterimage no colortable exists. This does not matter because the system assigns colors itself. But sometimes the user wants to create a own colortable. There are several possibilities:

 

2.1 Assign a standard colortable

The first possibility is to use:

$ r.support

Here you find the possibility to choose a standard colortable, which can be also changed later on.

 

To assign this table you can also use:

$ r.colors

 

 

2.2 Change the colortable interactively

The module

$ d.colors

has a menudriven system to assign to each cell value (=category value) RGB-values manually.

 

To get an idea about these values a table of standard colors for toposheets follows:

 

Symboltype

R

G

B

0 - black - no data

0

0

0

1 - white color

255

255

255

2 - Forest (green)

184

240

153

3 - Waterbodies (light blue)

192

230

255

4 - Contours (brown)

179

102

26

5 - Digs (dark blue)

0

51

255

6 - Ground plans of houses etc. (black)

0

0

0

7 - Text (dark blue)

0

0

255

8 - Trees (green)

0

192

0

9 - (dark grey)

192

192

192

10 - (light grey)

<