test.r3.out.ascii.sh 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Tests for r3.out.ascii and r3.in.ascii
  2. # This script tests the export of voxel data using r3.out.ascii
  3. # as well as the import of the generated data with r3.in.ascii
  4. # using different row and depth ordering options.
  5. # We set up 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. # We create several (float, double, null value) voxel map
  11. # with value = col + row + depth.
  12. r3.mapcalc --o expr="volume_float = float(col() + row() + depth())"
  13. r3.mapcalc --o expr="volume_double = double(col() + row() + depth())"
  14. # Add null value information to test correct null value handling
  15. r3.mapcalc --o expr="volume_float_null = if(row() == 1 || row() == 5, null(), volume_float)"
  16. r3.mapcalc --o expr="volume_double_null = if(row() == 1 || row() == 5, null(), volume_double)"
  17. # We export float data in the first @test using different order and precision.
  18. # The created text @files are validated of correct ordering and null data handling.
  19. # All reference files are located in the r3.out.ascii directory.
  20. r3.out.ascii --o input=volume_float_null output=test_float_nsbt_null.txt dp=0 null=*
  21. r3.out.ascii --o -r input=volume_float_null output=test_float_snbt_null.txt dp=0 null=*
  22. r3.out.ascii --o -d input=volume_float_null output=test_float_nstb_null.txt dp=0 null=*
  23. r3.out.ascii --o -rd input=volume_float_null output=test_float_sntb_null.txt dp=0 null=*
  24. # Different precision and null values than default
  25. r3.out.ascii --o input=volume_float_null output=test_float_nsbt_null_prec5.txt dp=5 null=-1000
  26. r3.out.ascii --o -rd input=volume_float_null output=test_float_sntb_null_prec8.txt dp=8 null=-2000
  27. # Test the no header and grass6 compatibility flags
  28. r3.out.ascii --o -h input=volume_float_null output=test_float_nsbt_null_no_header.txt dp=3 null=*
  29. r3.out.ascii --o -c input=volume_float_null output=test_float_nsbt_null_grass6_comp_1.txt dp=3 null=*
  30. # Any row or depth order should be ignored in case grass6 compatibility is enabled
  31. # The result of comp_1, _2 and _3 must be identical
  32. r3.out.ascii --o -cr input=volume_float_null output=test_float_nsbt_null_grass6_comp_2.txt dp=3 null=*
  33. r3.out.ascii --o -crd input=volume_float_null output=test_float_nsbt_null_grass6_comp_3.txt dp=3 null=*
  34. # We export float data in the first @test using different order and precision.
  35. # The created text @files are validated of correct ordering and null data handling.
  36. # All reference files are located in the r3.out.ascii directory.
  37. r3.out.ascii --o input=volume_double_null output=test_double_nsbt_null.txt dp=0 null=*
  38. r3.out.ascii --o -r input=volume_double_null output=test_double_snbt_null.txt dp=0 null=*
  39. r3.out.ascii --o -d input=volume_double_null output=test_double_nstb_null.txt dp=0 null=*
  40. r3.out.ascii --o -rd input=volume_double_null output=test_double_sntb_null.txt dp=0 null=*
  41. # Different precision and null values than default
  42. r3.out.ascii --o input=volume_double_null output=test_double_nsbt_null_prec5.txt dp=5 null=-1000
  43. r3.out.ascii --o -rd input=volume_double_null output=test_double_sntb_null_prec8.txt dp=8 null=-2000
  44. # Test the no header and grass6 compatibility flags
  45. r3.out.ascii --o -h input=volume_double_null output=test_double_nsbt_null_no_header.txt dp=3 null=*
  46. r3.out.ascii --o -c input=volume_double_null output=test_double_nsbt_null_grass6_comp_1.txt dp=3 null=*
  47. # Any row or depth order should be ignored in case grass6 compatibility is enabled
  48. # The result of comp_1, _2 and _3 must be identical
  49. r3.out.ascii --o -cr input=volume_double_null output=test_double_nsbt_null_grass6_comp_2.txt dp=3 null=*
  50. r3.out.ascii --o -crd input=volume_double_null output=test_double_nsbt_null_grass6_comp_3.txt dp=3 null=*
  51. # In the third @test we import all the generated data using r3.in.ascii.
  52. # The created @raster maps should be identical to the map "volume_double_null".
  53. # The export of the created g3d map should use as @precision=0 for data validation.
  54. # The same raster name is used for all the imported data and so for the validation reference file.
  55. r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null.txt nv=*
  56. r3.in.ascii --o output=test_double_nsbt_null input=test_double_snbt_null.txt nv=*
  57. r3.in.ascii --o output=test_double_nsbt_null input=test_double_nstb_null.txt nv=*
  58. r3.in.ascii --o output=test_double_nsbt_null input=test_double_sntb_null.txt nv=*
  59. # Different precision and null values than default
  60. r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null_prec5.txt nv=-1000
  61. r3.in.ascii --o output=test_double_nsbt_null input=test_double_sntb_null_prec8.txt nv=-2000
  62. # Import grass6 legacy data
  63. r3.in.ascii --o output=test_double_nsbt_null input=test_double_nsbt_null_grass6_comp_1.txt
  64. # In this @preprocess step for the last test we create a large region and
  65. # generate large input data to test the handling of large files.
  66. g.region s=0 n=800 w=0 e=1200 b=0 t=50 res=10 res3=1.5 -p3
  67. r3.mapcalc --o expr="volume_double_large = double(col() + row() + depth())"
  68. # Add null value information
  69. r3.mapcalc --o expr="volume_double_null_large = if(row() == 1 || row() == 5, null(), volume_double_large)"
  70. # Now @test the export and import of large data without validation
  71. r3.out.ascii --o input=volume_double_null_large output=test_double_nsbt_null_large.txt dp=0 null=*
  72. r3.in.ascii --o output=test_double_nsbt_null_large input=test_double_nsbt_null_large.txt nv=*
  73. # Just for the logs
  74. r3.info test_double_nsbt_null_large
  75. # Show differences between references and created text files
  76. for i in `ls *.ref` ; do
  77. diff $i "`basename $i .ref`.txt" ;
  78. done
  79. rm *.txt