SHARE
TWEET

Untitled

a guest Sep 17th, 2019 159 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. # usage: sh terraintextureshading.sh demfile newname resolution XMIN YMIN XMAX YMAX
  3. # example: sh terraintextureshading.sh mydem.tif sylarna 4 XMIN YMIN XMAX YMAX
  4.  
  5. i="$1"
  6. f="$2"
  7. j="$3"
  8.  
  9. XMIN="$4"
  10. YMIN="$5"
  11. XMAX="$6"
  12. YMAX="$7"
  13.  
  14. slopefile2070="20 255 255 255
  15. 70 153 153 153"
  16. echo "$slopefile2070" > 20-70.txt
  17.  
  18.  
  19. slopefile3750="0 0 0 0
  20. 37 0 0 0
  21. 50 255 255 255"
  22. echo "$slopefile3750" > 37-50.txt
  23.  
  24. slopefile45="0 1 1 1
  25. 50 1 1 1
  26. 50.01 255 255 255"
  27. echo "$slopefile45" > 45.txt
  28.  
  29.  
  30. #beskär raster
  31. echo "xmin: $XMIN, $YMAX $XMAX $YMIN"
  32.  
  33. gdal_translate -projwin $XMIN $YMAX $XMAX $YMIN $i ${f}.tif
  34.  
  35. #skala om
  36. gdalwarp -tr $j $j -r cubic ${f}.tif ${f}_${j}m.tif
  37.  
  38. ## gaussian filter
  39. saga_cmd grid_filter 1 -INPUT ${f}_${j}m.tif -RESULT ${f}_${j}m_dn07 -SIGMA 0.7 -KERNEL_TYPE 0 -KERNEL_RADIUS 2
  40.  
  41. # konvertera till float
  42. gdal_translate -of EHdr -ot Float32 ${f}_${j}m_dn07.sdat ${f}_${j}m.flt
  43.  
  44. # rock shade
  45. texture 1.5 ${f}_${j}m.flt ${f}_${j}m_rock_1_5.flt
  46. texture_image +0.0 ${f}_${j}m_rock_1_5.flt ${f}_${j}m_rock_1_5_img.tif
  47.  
  48. # texture shade
  49. texture 1.0 ${f}_${j}m.flt ${f}_${j}m_terr_1_0.flt
  50. texture_image +2.0 ${f}_${j}m_terr_1_0.flt ${f}_${j}m_terr_1_0_img.tif
  51.  
  52. #hillshade
  53. gdaldem hillshade ${f}_${j}m.tif ${f}_${j}m_hillshade.tif -z 1.0 -s 1.0 -az 315.0 -alt 55.0 -of GTiff
  54.  
  55. #slope
  56. gdaldem slope ${f}_${j}m.tif ${f}_${j}m_slope.tif -s 1.0 -of GTiff
  57.  
  58. #färgsätt slope-mask
  59. gdaldem color-relief ${f}_${j}m_slope.tif 37-50.txt ${f}_${j}m_slope_37-50.tif
  60.  
  61. #färgsätt slope
  62. gdaldem color-relief ${f}_${j}m_slope.tif 20-70.txt ${f}_${j}m_slope_20-70.tif
  63.  
  64. #skapa mask till hk
  65. gdaldem color-relief ${f}_${j}m_slope.tif 45.txt ${f}_${j}m_slope_45.tif
  66. gdal_sieve.py -st 20 ${f}_${j}m_slope_45.tif ${f}_${j}m_slope_45_S30.tif
  67. gdal_polygonize.py ${f}_${j}m_slope_45_S30.tif -f "ESRI Shapefile" ${f}_mask.shp ${f}_mask DN
  68. ogr2ogr -where DN="255" ${f}_mask_clean.shp ${f}_mask.shp
  69.  
  70. cp ${f}_${j}m_terr_1_0_img.tfw ${f}_${j}m_slopeshade.tfw
  71.  
  72. rm ${f}.tif
  73. rm 45.txt
  74. rm 37-50.txt
  75. rm 20-70.txt
  76. rm ${f}_${j}m.tif
  77. rm ${f}_${j}m_dn07.*
  78. rm ${f}_${j}m.*
  79. rm *.hdr
  80. rm *.flt
  81. rm ${f}_${j}m_slope.tif
  82. rm ${f}_mask.*
  83. rm ${f}_${j}m_slope_45.*
  84. rm ${f}_${j}m_slope_45_S30.*
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top