test.r3.to.rast.sh 2.3 KB

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