In this exercise a Digital Terrain Model (DTM) will be built starting from vector contour lines.
One of the recurring tasks when using GRASS is data import from a non native GRASS format: in this exercise the import of a vector file in the Shape format is shown. The map will be then transformed into a raster and it will be used to create a DTM.
First of all download the SHAPE contours.tgz and decompress it in your home directory.
Then start from the GRASS menu the command File -> Import vector map -> Common import formats.
The program requires the full path to the shape file (already decompressed) to be imported, in this case it should be /home/user-name (replace your user-name); most of the available options should be leaved to their default. The name of the importad map in GRASS is automatically set to the name of the shape file, but it can be changed by double-clicking on it (in the third column, Name for GRASS map). Here the default "contours" name will be used.
The process' output is shown in the following window:
To view the contour level map that has just been created, locate in the GIS layer Manager the button . A window in which it is possible to set all the parameters of the vector map to be displayed will appear. Click and select from the list the contours vector map just created. Check the next image to make sure you have carried out the procedure correctly (it is similar to that used to view a raster map).
The height of each contour line of the imported map are stored as attributes and they can be queried directly using the icon on the Map Display and clicking on the contour line: attributes are shown in the Output window of the GIS Layer Manager:
Obtaining a raster map from a vector one always implies an approximation. In this case, since linear objects are transformed, a suitable resolution must be set to limit the approximation. First of all, use g.region: Settings -> Region -> Set region, and select the tab: Resolution. Set the resolution using the field Grid resolution 2D inserting the value 1 (the measurement unit being the meter). Select the tab: Existing and insert in the field Set region to match this vector map the name of the vector map that must be converted into a raster, in our case contours. Once you are done click Run. Now the current region covers the whole contours map with 1 meter resolution.
Now, to carry out the conversion, open the v.to.rast window by selecting File -> Map type conversions -> Vector to raster.
The name chosen for the output map is
contours_raster, by checking the first option as shown in the figure, the new created map will be added to the GIS Layer Manager list.
Clicking on the tab Attributes it is possible to define the name of the column used to get the height attribute of each line, in our case: level.
To check the correspondence between vector contour lines and the newly created map, zoom in a small area and overlay the contours vector map to the contours_raster raster map, adding the first one to the Layer Manager (make sure the vector map is on top of the raster one). You should see perfect correspondence.