test.r3.cross.rast.sh 2.1 KB

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