1
# This script tests the r3.cross.rast to compute
2
# cross section raster maps based on a raster3d and elevation map
4
# We need to set a specific region in the
5
# @preprocess step of this test. We generate
6
# raster and voxel data with r.mapcalc and r3.mapcalc
7
# The region setting should work for UTM and LL test locations
8
g.region s=0 n=80 w=0 e=100 b=0 t=50 res=10 res3=10 -p3
9
# We create several evlevation maps to create slices of the voxel map
10
# We start from bottom and raise to the top
11
r.mapcalc --o expr="elev_0 = 0"
12
r.mapcalc --o expr="elev_1 = 5"
13
r.mapcalc --o expr="elev_2 = 15"
14
r.mapcalc --o expr="elev_3 = 25"
15
r.mapcalc --o expr="elev_4 = 35"
16
r.mapcalc --o expr="elev_5 = 45"
17
r.mapcalc --o expr="elev_NAN = 50"
18
r.mapcalc --o expr="elev_cross = float(col()* 5)"
19
# Now create a voxel map with value = col + row + depth.
20
r3.mapcalc --o expr="volume = col() + row() + depth()"
21
# Add null value information
22
r3.mapcalc --o expr="volume_null = if(row() == 1 || row() == 5, null(), volume)"
24
# We @test the creation of slices and a cross section of the voxel map. Reference data
25
# for @raster map validation is located in the r3.cross.rast source directory.
26
# Slice 0 and 1 should be identical. The last slice should be NAN.
27
r3.cross.rast --o input=volume_null elevation=elev_0 output=test_cross_section_slice_0
28
r3.cross.rast --o input=volume_null elevation=elev_1 output=test_cross_section_slice_1
29
r3.cross.rast --o input=volume_null elevation=elev_2 output=test_cross_section_slice_2
30
r3.cross.rast --o input=volume_null elevation=elev_3 output=test_cross_section_slice_3
31
r3.cross.rast --o input=volume_null elevation=elev_4 output=test_cross_section_slice_4
32
r3.cross.rast --o input=volume_null elevation=elev_5 output=test_cross_section_slice_5
33
r3.cross.rast --o input=volume_null elevation=elev_NAN output=test_cross_section_slice_NAN
34
r3.cross.rast --o input=volume_null elevation=elev_cross output=test_cross_section_result
36
# Export of the text files
37
for i in `g.list type=raster pattern=test_cross_section_*` ; do
38
r.out.ascii input=$i output=${i}.txt;
41
# Comparison of references and text files
42
for i in `ls *.ref` ; do
43
diff $i "`basename $i .ref`.txt" ;