1
# This script tests the conversion of voxel data
2
# into raster data slices. Validation data for each test
3
# is located in the module source directory
5
# We need to set a specific region in the
6
# @preprocess step of this test. We generate
7
# voxel data with r3.mapcalc. The region setting
8
# should work for UTM and LL test locations
9
g.region s=0 n=80 w=0 e=120 b=0 t=50 res=10 res3=10 -p3
10
# Now create a voxel map with value = col + row + depth.
11
r3.mapcalc --o expr="volume = double(col() + row() + depth())"
12
# Add null value information
13
r3.mapcalc --o expr="volume_null = if(row() == 1 || row() == 5, null(), volume)"
14
# Create floating point map
15
r3.mapcalc --o expr="volume_null_float = float(volume_null)"
18
# First we @test with identical region settings for raster and voxel data
19
# Reference data for all generated @raster maps are located in the r3.to.rast source directory.
20
r3.to.rast --o input=volume_null output=test_raster_slice_1
21
r3.to.rast --o input=volume_null_float output=test_raster_slice_float
23
# Export of the references
24
for i in `g.list type=raster pattern=test_raster_slice_1*` ; do r.out.ascii input=$i output=${i}.txt; done
25
for i in `g.list type=raster pattern=test_raster_slice_float*` ; do r.out.ascii input=$i output=${i}.txt; done
27
# The next @preprocess step adjusts the raster region to increase the resolution by 2
30
# This @test should show the via nearest neighbour resampled data.
31
# Reference data for all generated @raster maps are located in the r3.to.rast source directory.
32
r3.to.rast --o input=volume_null output=test_raster_slice_2
34
# Export of the references
35
for i in `g.list type=raster pattern=test_raster_slice_2*` ; do r.out.ascii input=$i output=${i}.txt; done
37
# The next @preprocess step adjusts the raster region to increase the resolution by 2 again
40
# This @test should show the via nearest neighbour resampled data.
41
# Reference data for all generated @raster maps are located in the r3.to.rast source directory.
42
r3.to.rast --o input=volume_null output=test_raster_slice_3
44
# Export of the references
45
for i in `g.list type=raster pattern=test_raster_slice_3*` ; do r.out.ascii input=$i output=${i}.txt; done
47
# Comparison of references and text files
48
for i in `ls *.ref` ; do
49
diff $i "`basename $i .ref`.txt" ;